MedicalRecord
. A MedicalRecord
holds a few pieces of information, namely, the name of the patient, the date of birth (DOB), the last visit, and a diagnosis record. Your
MedicalRecord
class will have the following data membersprivate String name
private String dateOfBirth
private String lastVisit
private String diagnosis
as well as setters and getters for each one these.
You will also add the following methods:
toString()
which returns the record formatted as seen belowMedicalRecord(String name)
which constructs one instance with the given patient's nameappendDiagnosis(String msg)
which appendsmsg
to the currentdiagnosis
.
public static void main(String[] args) { MedicalRecord bob = new MedicalRecord("Bob Smith"); bob.setDob("01/01/1960"); System.out.println(bob); System.out.println("---"); bob.setLastVisit("02/01/2012"); System.out.println(bob); System.out.println("---"); bob.setDiagnosis("OK"); System.out.println(bob); System.out.println("---"); bob.appendDiagnosis("1/1/12- His head hurts"); bob.appendDiagnosis("1/2/12- His toe is green"); System.out.println(bob); System.out.println("---"); bob.appendDiagnosis("1/10/12- OK now"); System.out.println(bob); System.out.println("---"); }when run with your class should print out:
Bob Smith Born: 01/01/1960 Last visit: null Diagnosis: null --- Bob Smith Born: 01/01/1960 Last visit: 02/01/2012 Diagnosis: null --- Bob Smith Born: 01/01/1960 Last visit: 02/01/2012 Diagnosis: OK --- Bob Smith Born: 01/01/1960 Last visit: 02/01/2012 Diagnosis: OK 1/1/12- His head hurts 1/2/12- His toe is green --- Bob Smith Born: 01/01/1960 Last visit: 02/01/2012 Diagnosis: OK 1/1/12- His head hurts 1/2/12- His toe is green 1/10/12- OK now ---
No comments:
Post a Comment