Task 2: General Abstracts For this task you will be asked to create the Java classes described in the UML diagram in Task 1. Instructions 1. The class Person has the following implementations in addition to those specified above: • the dateOfBirth attribute is of type java.util.Date • public getter methods for the attributes • a public constructor Person with the following method signature: public Person(String idNumber, String name, Date dateOfBirth) • declare an abstract compareTo method in Person with the following signature: public int compareTo(Person p); 2. The class called VaccineRecord has the following extra details: • the enum called VaccineType has the following possible values: JJ, AZ, MD, PF • the public constructor for the VaccineRecord has the following signa- ture: public VaccineRecord(VaccineType type, String batchCode); • the date attribute is of type java.util.Date 3. The class called Patient that extends the Person class has the following additional attributes and behaviours: • the public method called vaccinate takes a VaccineRecord and adds it to the vaccinationRecord list • a constructor with the following method signature: public Patient(String idNumber, String name, Date dateOfBirth); 4. The class called MedicalPractitioner has the following additional at- tributes and behaviours: • a public constructor with the following method signature: public MedicalPractitioner(String idNumber, String name, Date dateOfBirth, String licenseCode); • the vaccinate method creates a new VaccineRecord using the VaccineType and batchCode and calls the vaccinate method on the Patient. The method signature is as follows: public void vaccinate(VaccineRecord.VaccineType vaccineType, String batchCode, Patient patient); Sample Input/Output The following demo code produces the sample output: import java.util.Date; public class AssignmentDemo { public static void main(String[] args) { MedicalPractitioner nurseJoy = new MedicalPractitioner("6405013145087", "Nurse Joy", new Date(-178934400000L), "p0k3m0n-k4nt0"); Patient ashKetchum = new Patient("9906014269088", "Ash Ketchum", new Date(928195200000L)); System.out.printf("Name: %s\nRSA ID:%s\nDOB:%s\nVaccinated?: %b\n", ashKetchum.getName(), ashKetchum.getIdNumber(), ashKetchum.getDateOfBirth(), ashKetchum.isVaccinated()); nurseJoy.vaccinate(VaccineRecord.VaccineType.JJ, "batch-x0j2", ashKetchum); System.out.println("----------------------------"); System.out.printf("Name: %s\nRSA ID:%s\nDOB:%s\nVaccinated?: %b\n", ashKetchum.getName(), ashKetchum.getIdNumber(), ashKetchum.getDateOfBirth(), ashKetchum.isVaccinated()); } } Name: Ash Ketchum RSA ID:9906014269088 DOB:Tue Jun 01 02:00:00 SAST 1999 Vaccinated?: false ----------------------------
Task 2: General Abstracts
For this task you will be asked to create the Java classes described in the UML
diagram in Task 1.
Instructions
1. The class Person has the following implementations in addition to those
specified above:
• the dateOfBirth attribute is of type java.util.Date
• public getter methods for the attributes
• a public constructor Person with the following method signature:
public Person(String idNumber, String name, Date dateOfBirth)
• declare an abstract compareTo method in Person with the following
signature:
public int compareTo(Person p);
2. The class called VaccineRecord has the following extra details:
• the enum called VaccineType has the following possible values:
JJ,
AZ,
MD,
PF
• the public constructor for the VaccineRecord has the following signa-
ture:
public VaccineRecord(VaccineType type, String batchCode);
• the date attribute is of type java.util.Date
3. The class called Patient that extends the Person class has the following
additional attributes and behaviours:
• the public method called vaccinate takes a VaccineRecord and adds
it to the vaccinationRecord list
• a constructor with the following method signature:
public Patient(String idNumber, String name, Date dateOfBirth);
4. The class called MedicalPractitioner has the following additional at-
tributes and behaviours:
• a public constructor with the following method signature:
public MedicalPractitioner(String idNumber, String name, Date dateOfBirth, String licenseCode);
• the vaccinate method creates a new VaccineRecord using the
VaccineType and batchCode and calls the vaccinate method on
the Patient. The method signature is as follows:
public void vaccinate(VaccineRecord.VaccineType vaccineType, String batchCode, Patient patient);
Sample Input/Output
The following demo code produces the sample output:
import java.util.Date;
public class AssignmentDemo {
public static void main(String[] args) {
MedicalPractitioner nurseJoy = new MedicalPractitioner("6405013145087", "Nurse Joy", new Date(-178934400000L), "p0k3m0n-k4nt0");
Patient ashKetchum = new Patient("9906014269088", "Ash Ketchum", new Date(928195200000L));
System.out.printf("Name: %s\nRSA ID:%s\nDOB:%s\nVaccinated?: %b\n", ashKetchum.getName(), ashKetchum.getIdNumber(), ashKetchum.getDateOfBirth(), ashKetchum.isVaccinated());
nurseJoy.vaccinate(VaccineRecord.VaccineType.JJ, "batch-x0j2", ashKetchum);
System.out.println("----------------------------");
System.out.printf("Name: %s\nRSA ID:%s\nDOB:%s\nVaccinated?: %b\n", ashKetchum.getName(), ashKetchum.getIdNumber(), ashKetchum.getDateOfBirth(), ashKetchum.isVaccinated());
}
}
Name: Ash Ketchum
RSA ID:9906014269088
DOB:Tue Jun 01 02:00:00 SAST 1999
Vaccinated?: false
----------------------------
Step by step
Solved in 2 steps