Question
Modify the Ward class and build a Bed class to work with the other classes. Java programming. ************************* Other classes complete already. Person,Patient,Doctor,Surgeon: //Person.java /**
Modify the Ward class and build a Bed class to work with the other classes. Java programming.
*************************
Other classes complete already. Person,Patient,Doctor,Surgeon:
//Person.java /** * The model of a person who has a name and a health number * that cannot be changed. */ public abstract class Person { /** * The name of the person. */ private String pname; /** * The health number of the person. */ private int healthNum; private int age; private String address; /** * Initialize an instance with the given name and health number. * * @param pName the person's name * @param pNumber the person's health number */ public Person(String pname, int age, String address) { this.pname = pname; this.age = age; this.address = address; } /** * Return the name of the person. * * @return the name of the person */ public String getName() { return pname; } /** * Return the health number of the person. * * @return the health number of the person */ public int getHealthNumber() { return healthNum; } /** * Change the name of the person. * * @param newName the name of the person */ public void setName(String newName) { pname = newName; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } /** * Return a string representation of the person. * * @return a string representation of the person */ @Override public String toString() { return "Name: "+pname+" Age: "+age+" Address: "+address; } } /** * A method to test the Person class. */
//Patient.java import java.util.LinkedList; public class Patient extends Person{ String bedReference; LinkedList
// Doctor.java import java.util.LinkedList; import java.util.List; public class Doctor extends Person implements BasicDoctor{ String department; int experience; public List
// Surgeon.java public class Surgeon extends Doctor{ public Surgeon(String name, int age, String address, int experience, String department) { super(name, age, address, experience, department); } @Override public String toString() { return "Surgeon: "+getName()+" Age: "+getAge()+" Address: "+getAddress()+" Designation: "+department+" With experience of: "+experience; } }
// interface BasicDoctor.java // all are in package card public interface BasicDoctor { public Person checkUp() throws Exception; }
Modifications to Ward class: The Ward class from Assignment 2 should be modified so that the array is now a linked list of type Bed. When this change is made, a number of the methods will need to be changed in order to be consistent with type Bed being stored in the linked list. In addition, two methods need to be added to the Ward class. The first is to obtain an empty bed of the correct purpose in the ward if one exists. The second one is to remove a Patient from a specific bed. These changes are to be done to the existing Ward class, i.e, you are not define a descendant of Ward. When you create a Ward object, you must also specify how many of each of the three beds (by purpose) the ward has. It is ok to specify 0 if no beds of that type exist in the ward. Bed class: This class represents beds in the ward. Each bed knows (has a reference to) which ward it belongs to. It also has a reference to the patient that is in the bed (null if it is empty). It will require methods to assign a patient to the bed (where it can refuse if a patient already exists) and to remove a patient when the patient leaves the bed. Also provide a method isEmpty0 returning true if the bed is empty and false otherwise. Along with the properties of ward and patient, each bed has a label (string identifying the bed, ex. "Bed1") anda purpose: general care burn recovery . surgical recovery Modifications to Ward class: The Ward class from Assignment 2 should be modified so that the array is now a linked list of type Bed. When this change is made, a number of the methods will need to be changed in order to be consistent with type Bed being stored in the linked list. In addition, two methods need to be added to the Ward class. The first is to obtain an empty bed of the correct purpose in the ward if one exists. The second one is to remove a Patient from a specific bed. These changes are to be done to the existing Ward class, i.e, you are not define a descendant of Ward. When you create a Ward object, you must also specify how many of each of the three beds (by purpose) the ward has. It is ok to specify 0 if no beds of that type exist in the ward. Bed class: This class represents beds in the ward. Each bed knows (has a reference to) which ward it belongs to. It also has a reference to the patient that is in the bed (null if it is empty). It will require methods to assign a patient to the bed (where it can refuse if a patient already exists) and to remove a patient when the patient leaves the bed. Also provide a method isEmpty0 returning true if the bed is empty and false otherwise. Along with the properties of ward and patient, each bed has a label (string identifying the bed, ex. "Bed1") anda purpose: general care burn recovery . surgical recoveryStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started