de.thaw.ps1.blatt7
Class BloodType

java.lang.Object
  extended by de.thaw.ps1.blatt7.BloodType

 class BloodType
extends Object

Modelliert Blutgruppen.


Field Summary
(package private) static int A
           
(package private) static int A_NEGATIVE
           
(package private) static int A_POSITIVE
           
(package private) static int A1
           
(package private) static int A2
           
(package private) static int AB
          Definition einer auf kombinierten Genen basierenden Blutgruppe.
(package private) static int AB_NEGATIVE
           
(package private) static int AB_POSITIVE
           
private static int ALL_GENES
           
(package private) static int B
           
(package private) static int B_NEGATIVE
           
(package private) static int B_POSITIVE
           
private  int bloodType
          Diese Blutgruppe.
(package private) static int D
           
(package private) static BloodType[] instance
          Stellt eine Liste aller potentiell existierenden Blutgruppen dar.
(package private) static int NONE
          Definition einer Blutgruppengenart.
(package private) static int NULL_NEGATIVE
           
(package private) static int NULL_POSITIVE
           
 
Constructor Summary
private BloodType(int bloodType)
          Privater Konstruktor.
 
Method Summary
(package private)  int bloodType()
          Zugriffsmethode.
private static int geneRandomness()
          Erstellt einen Zufälligkeitsfaktor für neue Blutgruppen.
(package private) static BloodType instance(int bloodType)
          Singleton-Konstruktor.
(package private) static BloodType random()
          Erstellt eine zufällige neue Blutgruppe.
(package private) static BloodType random(BloodTypeCarrier parent1, BloodTypeCarrier parent2)
          Erstellt eine medizinisch gesehen mögliche, zufällige neue Blutgruppe anhand zweier Eltern-Blutgruppen.
private static BloodType random(int parent1BloodType, int parent2BloodType)
          Erstellt eine medizinisch gesehen mögliche, zufällige neue Blutgruppe anhand zweier Eltern-Blutgruppen.
private  void setBloodType(int bloodType)
          Zugriffsmethode.
 String toString()
          Beschreibt diese Blutgruppe textuell.
private static int validate(int bloodType)
          Überprüft, ob die angegebene Blutgruppe existieren kann.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

static final int NONE
Definition einer Blutgruppengenart.

See Also:
Constant Field Values

A

static final int A
See Also:
Constant Field Values

B

static final int B
See Also:
Constant Field Values

D

static final int D
See Also:
Constant Field Values

A1

static final int A1
See Also:
Constant Field Values

A2

static final int A2
See Also:
Constant Field Values

ALL_GENES

private static final int ALL_GENES
See Also:
Constant Field Values

AB

static final int AB
Definition einer auf kombinierten Genen basierenden Blutgruppe.

See Also:
Constant Field Values

NULL_NEGATIVE

static final int NULL_NEGATIVE
See Also:
Constant Field Values

A_NEGATIVE

static final int A_NEGATIVE
See Also:
Constant Field Values

B_NEGATIVE

static final int B_NEGATIVE
See Also:
Constant Field Values

AB_NEGATIVE

static final int AB_NEGATIVE
See Also:
Constant Field Values

NULL_POSITIVE

static final int NULL_POSITIVE
See Also:
Constant Field Values

A_POSITIVE

static final int A_POSITIVE
See Also:
Constant Field Values

B_POSITIVE

static final int B_POSITIVE
See Also:
Constant Field Values

AB_POSITIVE

static final int AB_POSITIVE
See Also:
Constant Field Values

instance

static BloodType[] instance
Stellt eine Liste aller potentiell existierenden Blutgruppen dar. Da mehrere Menschen mit derselben Blutgruppe nicht jeweils eine eigene Instanz der Blutgruppe benötigen, werden alle existierenden Blutgruppen hier zur Wiederverwendung gesammelt.


bloodType

private int bloodType
Diese Blutgruppe.

Constructor Detail

BloodType

private BloodType(int bloodType)
Privater Konstruktor. Da es sich um eine erweiterte Singleton-Klasse handelt, darf der Konstruktor nicht von der Anwendung aufgerufen werden.

Parameters:
bloodType - die Blutgruppe der neuen Instanz
Method Detail

instance

static final BloodType instance(int bloodType)
                         throws IllegalArgumentException
Singleton-Konstruktor. Erstellt eine (indizierte) Instanz, falls diese noch nicht erstellt wurde.

Parameters:
bloodType - die Blutgruppe der neuen Instanz
Returns:
die Blutgruppen-Instanz der spezifizierten Blutgruppe
Throws:
IllegalArgumentException - falls die übergebene Blutgruppe nicht existieren kann

bloodType

int bloodType()
Zugriffsmethode.

Returns:
diese Blutgruppe
See Also:
bloodType

setBloodType

private void setBloodType(int bloodType)
                   throws IllegalArgumentException
Zugriffsmethode.

Parameters:
bloodType - die Blutgruppe der neuen Instanz
Throws:
IllegalArgumentException - falls die übergebene Blutgruppe nicht existieren kann
See Also:
bloodType

validate

private static int validate(int bloodType)
                     throws IllegalArgumentException
Überprüft, ob die angegebene Blutgruppe existieren kann. Beispielsweise würde eine Angabe, aus der Zugehörigkeit zur Sub-Gruppe A1, aber nicht zur Haupt-Gruppe A hervorgeht, als ungültig abgelehnt.

Parameters:
bloodType - die zu testende Blutgruppe
Returns:
int die Blutgruppe, falls der Test erfolgreich war
Throws:
IllegalArgumentException, - falls der Test nicht erfolgreich war
IllegalArgumentException

random

static BloodType random(BloodTypeCarrier parent1,
                        BloodTypeCarrier parent2)
Erstellt eine medizinisch gesehen mögliche, zufällige neue Blutgruppe anhand zweier Eltern-Blutgruppen.

Parameters:
parent1 - Elternteil-Blutsgruppe
parent2 - Elternteil-Blutsgruppe
Returns:
eine neue natürliche Blutsgruppe

random

static BloodType random()
Erstellt eine zufällige neue Blutgruppe.

Returns:
eine neue Blutsgruppe

random

private static BloodType random(int parent1BloodType,
                                int parent2BloodType)
Erstellt eine medizinisch gesehen mögliche, zufällige neue Blutgruppe anhand zweier Eltern-Blutgruppen.

Parameters:
parent1BloodType - Elternteil-Blutsgruppe
parent2BloodType - Elternteil-Blutsgruppe
Returns:
eine neue natürliche Blutsgruppe

geneRandomness

private static int geneRandomness()
Erstellt einen Zufälligkeitsfaktor für neue Blutgruppen. Dieser Faktor ist äußerst unrealistisch: Er nimmt an, dass die Wahrscheinlichkeit für ein bestimmtes Gen immer 0.5 ist.

Returns:
ein zufälliger Faktor

toString

public String toString()
Beschreibt diese Blutgruppe textuell.

Overrides:
toString in class Object
Returns:
eine Text-Repräsentation dieser Blutgruppe.