Draw the UML class diagrams for the following classes: An abstract Java class called Person that has the following attributes: a String called idNumber a Date called dateOfBirth representing the date of birth. a String for name A class called VaccineRecord with the following attributes: an enum called type of VaccineType a Date called date a String called batchCode A class called Patient that extends the Person class and has the following attributes and behaviours: an ArrayList that contains VaccineRecord objects called vaccinationRecord a public method called vaccinate that takes a VaccineRecord with the following signature: public void vaccinate(VaccineRecord vaccineRecord); a public boolean method called isVaccinated that returns whether or not the Patient has had a vaccine. A MedicalPractitioner class that extends the Person class and has the following attributes and behaviours: a String called licenseCode a public method called vaccinatePatient that takes as a parameter a Patient object, a VaccineType, and a String batchCode 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 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); 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 signature: public VaccineRecord(VaccineType type, String batchCode); the date attribute is of type java.util.Date 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); The class called MedicalPractitioner has the following additional attributes 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); Input running code 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()); } } Output Name: Ash Ketchum RSA ID:9906014269088 DOB:Tue Jun 01 02:00:00 SAST 1999 Vaccinated?: false ---------------------------- Name: Ash Ketchum RSA ID:9906014269088 DOB:Tue Jun 01 02:00:00 SAST 1999 Vaccinated?: true
Draw the UML class diagrams for the following classes:
- An abstract Java class called Person that has the following attributes:
- a String called idNumber
- a Date called dateOfBirth representing the date of birth.
- a String for name
- A class called VaccineRecord with the following attributes:
- an enum called type of VaccineType
- a Date called date
- a String called batchCode
- A class called Patient that extends the Person class and has the following attributes and behaviours:
- an ArrayList that contains VaccineRecord objects called vaccinationRecord
- a public method called vaccinate that takes a VaccineRecord with the following signature:
public void vaccinate(VaccineRecord vaccineRecord);- a public boolean method called isVaccinated that returns whether or not the Patient has had a vaccine.
- A MedicalPractitioner class that extends the Person class and has the following attributes and behaviours:
- a String called licenseCode
- a public method called vaccinatePatient that takes as a parameter a Patient object, a VaccineType, and a String batchCode
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
- 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); - The class called VaccineRecord has the following extra details:
- the enum called VaccineType has the following possible values:
- the public constructor for the VaccineRecord has the following signature:
- the date attribute is of type java.util.Date
- 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); - The class called MedicalPractitioner has the following additional attributes 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);
Input
running code
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()); } }
Output
Name: Ash Ketchum RSA ID:9906014269088 DOB:Tue Jun 01 02:00:00 SAST 1999 Vaccinated?: false ---------------------------- Name: Ash Ketchum RSA ID:9906014269088 DOB:Tue Jun 01 02:00:00 SAST 1999 Vaccinated?: true
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images