BloodType

o1.blood1.BloodType
class BloodType(val abo: String, val rhesus: Boolean)

An instance of this class corresponds to a single blood type in an ABO+Rh blood group system. A person’s blood type affects who they can donate blood to; the blood types of the donor and the recipient must be compatible.

As represented here, a blood type consists of two components, ABO and rhesus. For any person, the ABO component has one of the following values: "A", "B", "AB", or "O" (the letter O, not zero). The rhesus component is either positive or negative. These components describe the presence or absence of particular antigens in human blood; for further reading, see Wikipedia.

This class reprents the ABO component as a string and the rhesus component as a boolean so that true corresponds to positive and false to negative.

Parameters

abo

the ABO component of the blood type; this must be one of the strings "A", "B", "AB", or "O", or the class will malfunction

rhesus

the rhesus component of the blood type; true stands positive, false for negative

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def canDonateTo(recipient: BloodType): Boolean

Determines whether the person with this blood type can safely donate blood to the given recipient, taking into account both the ABO and rhesus components. The donor’s blood must be safe for the recipient in both respects, as defined under methods hasSafeABOFor and hasSafeRhesusFor.

Determines whether the person with this blood type can safely donate blood to the given recipient, taking into account both the ABO and rhesus components. The donor’s blood must be safe for the recipient in both respects, as defined under methods hasSafeABOFor and hasSafeRhesusFor.

Parameters

recipient

the blood type of the person who would receive the blood of this type

Attributes

Determines whether the person with this blood type can safely receive blood donated by the given person. Both the ABO and rhesus components are taken into account, the same way as in canDonateTo.

Determines whether the person with this blood type can safely receive blood donated by the given person. Both the ABO and rhesus components are taken into account, the same way as in canDonateTo.

Parameters

donor

the blood type of the donor

Attributes

def hasSafeABOFor(recipient: BloodType): Boolean

Determines whether the person with this blood type can safely donate blood to the given recipient, as far as the ABO component is concerned. Blood of type A can be safely donated to recipients with type A or AB; blood of type B to recipients of type B or AB; blood of type O to recipients with any ABO type; and blood of type AB only to recipients who also have AB blood. More information: Red Blood Cell Compatibility.

Determines whether the person with this blood type can safely donate blood to the given recipient, as far as the ABO component is concerned. Blood of type A can be safely donated to recipients with type A or AB; blood of type B to recipients of type B or AB; blood of type O to recipients with any ABO type; and blood of type AB only to recipients who also have AB blood. More information: Red Blood Cell Compatibility.

Note that this method entirely ignores the rhesus component.

Parameters

recipient

the blood type of the person who would receive the blood of this type

Attributes

Determines whether the person with this blood type can safely donate blood to the given recipient, as far as the rhesus component is concerned. Blood with a negative rhesus component is safe to both positive and negative recipients; blood with a positive rhesus is only safe for positive recipients. More information: Red Blood Cell Compatibility.

Determines whether the person with this blood type can safely donate blood to the given recipient, as far as the rhesus component is concerned. Blood with a negative rhesus component is safe to both positive and negative recipients; blood with a positive rhesus is only safe for positive recipients. More information: Red Blood Cell Compatibility.

Note that this method entirely ignores the ABO component.

Parameters

recipient

the blood type of the person who would receive the blood of this type

Attributes

override def toString: String

Returns a string representation of the blood type. This will be one of "A", "B", "AB", or "O" followed by either "+" or "-". For example, if the type’s ABO component is "A" and its rhesus component false, this method returns "A-".

Returns a string representation of the blood type. This will be one of "A", "B", "AB", or "O" followed by either "+" or "-". For example, if the type’s ABO component is "A" and its rhesus component false, this method returns "A-".

Attributes

Definition Classes
Any

Concrete fields

val abo: String