Пример #1
0
 /**
  * Undoes the execution of this command
  *
  * @throws CannotDoException the command was not yet executed
  * @see Hospital.Factory.Command#undo()
  */
 @Override
 public String undo() throws CannotDoException {
   if (!done) {
     throw new CannotDoException("Cannot undo Command");
   }
   appC.undo();
   toAdd.removeMedicalTest(made);
   done = false;
   return "Undone:\n" + this.toString();
 }
Пример #2
0
 /**
  * Executes the command by creating the medical test
  *
  * @return the details of the created medical test
  * @throws CannotDoException the command was already executed
  */
 @Override
 public String execute() throws CannotDoException {
   if (done) {
     throw new CannotDoException("Cannot undo command, not done yet.");
   }
   if (made.isResultEntered()) {
     throw new CannotDoException("Results already entered, cannot undo.");
   }
   String out = appC.execute();
   toAdd.addMedicalTest(made);
   done = true;
   return out + "\n" + made.advancedString();
 }
Пример #3
0
 /**
  * @return the details of the medical test and the patient it was made for
  * @see java.lang.Object#toString()
  */
 @Override
 public String toString() {
   return made.toString() + "\nPatient: " + toAdd.toString();
 }