Wednesday, February 8, 2012

Lab 9: Medical Records

In this lab you will implement your first class: 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 members
  1. private String name
  2. private String dateOfBirth
  3. private String lastVisit
  4. private String diagnosis

as well as setters and getters for each one these.

You will also add the following methods:
  1. toString() which returns the record formatted as seen below
  2. MedicalRecord(String name) which constructs one instance with the given patient's name
  3. appendDiagnosis(String msg) which appends msg to the current diagnosis.

For example, the following code:
 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: