Beispiel #1
0
  public boolean removePatient(Patient aPatient) {
    boolean wasRemoved = false;
    if (!patients.contains(aPatient)) {
      return wasRemoved;
    }

    int oldIndex = patients.indexOf(aPatient);
    patients.remove(oldIndex);
    if (aPatient.indexOfDoctor(this) == -1) {
      wasRemoved = true;
    } else {
      wasRemoved = aPatient.removeDoctor(this);
      if (!wasRemoved) {
        patients.add(oldIndex, aPatient);
      }
    }
    return wasRemoved;
  }
Beispiel #2
0
 public boolean addPatient(Patient aPatient) {
   boolean wasAdded = false;
   if (patients.contains(aPatient)) {
     return false;
   }
   if (patients.contains(aPatient)) {
     return false;
   }
   patients.add(aPatient);
   if (aPatient.indexOfDoctor(this) != -1) {
     wasAdded = true;
   } else {
     wasAdded = aPatient.addDoctor(this);
     if (!wasAdded) {
       patients.remove(aPatient);
     }
   }
   return wasAdded;
 }