Question: Create a class Patient that can be used to represent a patient in a hospital. The class should at least have the following instance variables:
Create a class Patient that can be used to represent a patient in a hospital. The class should at least have the following instance variables: patientName: the name of the patient patientID: a unique identifier for each patient entryDate: the date when the patiened was admitted to the hospital doctor: the doctor assigned to the patientThen, implement all constructors, copy constructor, accessors and mutators, toString and equals methods. Show me when you have done this.
Create a class called Doctor that represents a doctor in a hospital. The class should at least have the following instance variables and methods: doctorName: the name of the doctor doctorID: a unique identifier for each doctor specialization the specialized area of the doctor patients: the array of all patient objects assigned to the doctor.A doctor can be in charge at most patients noOfPatients: the number of patients currently assigned to the doctor isAvailable: the boolean variable which is false if any patients are assigned to the doctor. void assignPatientPatient p: assigns a patient to the doctor Then, implement all constructors, accessors and mutators, toString and equals methods. Show me when you have done this Write a driver that creates Patient and Doctor objects and test all the methods you have defined in the classes. Print out information on each object right after creation and after every method call. Run your code and show me your outputsDesign and implement a class Hospital by analogy with class Company. A hospital object will store the following variables and methods: hospitalName: the name of the hospital numberOfDoctors: number of doctors currently working at the hospital numberOfPatients: number of patients currently admitted to the hospital. doctors: array of doctor objects working in the hospital patients: array of patient objects admitted to the hospital sizeOfDoctors: doctor capacity of the hospital which is used as the size of the doctors array sizeOfPatients: patient capacity of the hospital which is used as the size of the patients array The constructor of the Hospital class should initialize all instance variables. However, the patient and doctor arrays should initially be emptythat is you should not create any patient and doctor objects in the constructor Provide the methods: void addPatient Patient p: which takes a single Patient object as argument and admits this patient to the hospital by assigning the patient to the first available doctor in the hospital. Be careful about privacy leaks. void addDoctorDoctor d: adds a doctor to the hospital staff Patient findPatient String name: which takes a name as an argument, and if that name is found as one of the patient names in the hospital, it returns a reference to a copy of the found patient object. Doctor findDoctor String id: which takes an id as an argument, and if that id is an id of a doctor at the hospital, it returns a reference to a copy of the found doctor objects void removePatientPatient p: which takes a single Patient object as argument and removes the argument from both the patient array of hostipal and the patient array of the doctor assigned to that patient. Be careful while removing the Patient element from the arrays. You need to shift the elements with higher indexes down to fill in the gap that is left by the removed element.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
