Question: It is a java program Assignment overview In this assignment, you will implement a set of related classes of objects: Patient: A patient hoping to

It is a java program

Assignment overview

In this assignment, you will implement a set of related classes of objects:

Patient: A patient hoping to receive a vaccination

HealthID: A class that represents and provides health identification numbers for patients

VaccineClinic: A clinic that receives vaccine doses, books patients and administers vaccines.

ProvincialCoordinator: Coordinates the vaccination process by distributing doses to registered clinics, and providing statistics on vaccinations to date.

Phase 1: Patient and HealthID

First, implement two simple classes: a Patient class and a HealthID class

The Patient class should have:

Four instance variables: the patients name (a String), their age (an int), their health ID (a HeathID see below) and a variable indicating whether or not they have been vaccinated (a boolean).

COMP 1020 Winter 2021

A constructor that has three parameters (String, int, HealthID), which are used to initialize the first three instance variables described above. A newly instantiated patient has not yet been vaccinated.

A standard toString() method, which returns a String containing the patients name, age, health ID and vaccine status. Format this string as shown in the output below.

An equals method that checks if two patients are equal. Two patients are equal if they have the same health ID.

Three accessor methods: isVaccinated() which returns the patients vaccination status, getHealthID()

which returns the patient HealthID and getName() which returns the patients name.

A void method vaccinate() which sets the patients vaccination status to true.

We will use the convention in Manitoba, where a health ID consists of a family number and a pin. Members of the same family will have the same family number, but each individual will have a unique pin. With this in mind, the HealthID class should have:

Two instance variables: the family number (an int) and the pin (an int).

Two class variables that represent the next family number (an int) and the next pin (an int) available. The family number should start at 1000 and the pin should start at 100000000. Each should be increased by 1 when used to initialize a new HealthID instance.

A constructor with no parameters, that initializes both instance variables using the next available family number and next available pin, respectively.

A constructor that accepts a single int, which is used to initialize the instances family number. The constructor should use the next available pin to initialize the other instance variable.

Two accessor methods getFamilyNumber() and getPIN() that return the values of the family number and pin instance variables respectively.

A toString() method which returns a String containing the family number and pin, separated by a colon (as shown below).

An equals method that checks if two HealthIDs are equal. Two HealthIDs are equal if they have the same family number and pin.

A boolean sameFamily method that takes another HealthID as a parameter and returns true if they have the same family number.

You can test your classes using the supplied test program TestPhase1.java. You should get the output below.

1000:100000000

Alice(68), 1000:100000000, Vaccinated:false

1000:100000001

Bob(70), 1000:100000001, Vaccinated:false Equals? false

Same family? true

1001:100000002

Yuwei(24), 1001:100000002, Vaccinated:false Same family? false

Vaccinating Alice

Is Alice vaccinated? true

Phase 2: VaccineClinic

Next, implement the VaccineClinic class, which represents the specification for a clinic that can receive and administer vaccine doses to Patients who have booked appointments.

The VaccineClinic class should have:

Four main instance variables: the name of the clinic (a String), the number of doses available (an int), the total number of doses administered (an int), and an array of Patients awaiting vaccines. Use a simple partially- filled array for this list of patients. Use a class constant to determine the size of your array, set to 100 for testing purposes. You may assume that the list will never become full no error checking is needed.

A constructor that accepts only one parameter, the clinics name (a String).

A constructor that accepts the clinics name (a String) and an initial supply of doses (an int).

A void method receiveMoreDoses(int) that is called when the clinic receives more doses of the vaccine.

An accessor method getDosesAdministered() that returns the number of doses administered by the clinic.

An accessor method getNumDosesAvailable() that returns the number of doses still available at the clinic.

A method schedulePatient(Patient) that adds the patient to the list of patients waiting to be vaccinated by the clinic. The patient should only be added to the list if: a) the clinic has enough supply to vaccinate the patient as well as all patients currently waiting and b) the patient has not already received the vaccine. For the purpose of this assignment, patients who receive one dose are considered fully vaccinated. The method should return an int representing the patients place in the queue or the value of an UNABLE_TO_SCHEDULE class constant if the patient was not added to the list. Make sure that the UNABLE_TO_SCHEDULE value does not correspond to a potential position in the queue.

A method display displayPatientsWaiting() which displays the list of waiting patients to the screen (see the output example below).

A method vaccinateNextPatient() that vaccinates the next patient in the list of patient awaiting vaccines. The class should implement a first-come-first-served policy when vaccinating patients from the list. As mentioned above, a patient is considered fully vaccinated after receiving one dose.

A method administerAvailableDoses() that vaccinates as many patients as possible by going through all of the clinics available doses, in a first-come-first-served order.

An equals method. Two clinics are considered equal if they have the same name.

A toString() method that returns a String containing the clinics name, the doses administered, the doses available and the number of Patients still waiting to be vaccinated (formatted as shown in the sample output below).

You can test your class with TestPhase2.java. You should get the output shown below.

Winnipeg Supersite: Administered(0) Supply(3) Booked(0) Patients waiting for vaccines at Winnipeg Supersite:

Scheduling alice, liqun, bob at the Winnipeg clinic Alice is in position: 1

Liqun is in position: 2 Bob is in position: 3

Winnipeg Supersite: Administered(0) Supply(3) Booked(3) Patients waiting for vaccines at Winnipeg Supersite: Alice(68), 1000:100000000, Vaccinated:false

Liqun(25), 1002:100000003, Vaccinated:false

Bob(70), 1000:100000001, Vaccinated:false

Trying to schedule Ananta at the Winnipeg clinic Ananta is position: -1

Winnipeg Supersite: Administered(0) Supply(3) Booked(3)

Brandon Supersite: Administered(0) Supply(0) Booked(0) Giving Brandon 2 more doses

Brandon Supersite: Administered(0) Supply(2) Booked(0)

Scheduling Ananta amd Taylor in Brandon

Brandon Supersite: Administered(0) Supply(2) Booked(2) Patients waiting for vaccines at Brandon Supersite:

Ananta(35), 1003:100000004, Vaccinated:false

Taylor(30), 1003:100000005, Vaccinated:false

Vaccinate next patient in Brandon

Patients waiting for vaccines at Brandon Supersite:

Taylor(30), 1003:100000005, Vaccinated:false

Brandon Supersite: Administered(1) Supply(1) Booked(1) Ananta(35), 1003:100000004, Vaccinated:true

Vaccinate next patient in Brandon

Patients waiting for vaccines at Brandon Supersite:

Brandon Supersite: Administered(2) Supply(0) Booked(0)

Vaccinate next patient in Brandon. There is nobody waiting, but the code shouldn't crash Patients waiting for vaccines at Brandon Supersite:

Give Winnipeg more doses

Winnipeg Supersite: Administered(0) Supply(8) Booked(3)

Use all of the doses in Winnipeg

Patients waiting for vaccines at Winnipeg Supersite:

Winnipeg Supersite: Administered(3) Supply(5) Booked(0)

Sarita is scheduled in position: 1

Patients waiting for vaccines at Winnipeg Supersite:

Sarita(24), 1004:100000006, Vaccinated:false

Winnipeg Supersite: Administered(3) Supply(5) Booked(1)

Phase 3: ProvincialCoordinator

Next implement the ProvincialCoordinator class, which will manage the different vaccine clinics. The ProvincialCoordinator class should have:

A String instance variable for the name of the province

Two int instance variables that keep track of the doses distributed to the clinics and the provinces population.

An instance variable containing a list of vaccine clinics operating in the province. Use a simple partially-filled array to do this. Use a class constant to determine the size of your array, initialized to 25 for testing purposes. You may assume that the list will never become full no error checking is needed.

A constructor that takes a String and an int and uses them to initialize the provinces name and population.

A method addClinic(VaccineClinic) which adds the clinic to the list.

A method distributeVaccinesToClinics(int) that receives new doses and distributes them evenly to all of its clinics. If the number of doses received does not evenly divide across the clinics, the last clinic in the list should get the remainder.

A getPercentagePopulationVaccinated() that returns a double representing the percentage of the population that has received vaccines.

A toString() method that returns a String containing the name of the province, the number of clinics, the total number of vaccines distributed, the total number of vaccines administered by the clinics, and the percentage of the population that has been vaccinated on the first line. The next line should contain Clinics: followed by a line for each of its clinics generated by calling each clinics toString() method, or None, if there are no registered clinics. See below for the format.

You can test your class with TestPhase3.java. You should get the output shown below:

Instantiating the coordinator

Manitoba: Clinics(0) Distributed(0) Administered(0) Population Vaccinated(0.0%) Clinics:

None

Creating the Winnipeg clinic and registering with the coordinator The province receives 4 vaccines to distribute to its clinics

Manitoba: Clinics(1) Distributed(4) Administered(0) Population Vaccinated(0.0%) Clinics:

Winnipeg Supersite: Administered(0) Supply(4) Booked(0)

Creating the Brandon clinic and registering with the coordinator

Manitoba: Clinics(2) Distributed(4) Administered(0) Population Vaccinated(0.0%) Clinics:

Winnipeg Supersite: Administered(0) Supply(4) Booked(0) Brandon Supersite: Administered(0) Supply(0) Booked(0)

Distributing 9 more doses to the clinics

Manitoba: Clinics(2) Distributed(13) Administered(0) Population Vaccinated(0.0%) Clinics:

Winnipeg Supersite: Administered(0) Supply(8) Booked(0) Brandon Supersite: Administered(0) Supply(5) Booked(0)

Scheduling some patients at the clinics

Manitoba: Clinics(2) Distributed(13) Administered(0) Population Vaccinated(0.0%) Clinics:

Winnipeg Supersite: Administered(0) Supply(8) Booked(3) Brandon Supersite: Administered(0) Supply(5) Booked(1)

Administer available doses at each clinic:

Manitoba: Clinics(2) Distributed(13) Administered(4) Population Vaccinated(0.4%) Clinics:

Winnipeg Supersite: Administered(3) Supply(5) Booked(0) Brandon Supersite: Administered(1) Supply(4) Booked(0)

Test phase 3

public class TestPhase3 { public static void main(String[] args) { System.out.println("Instantiating the coordinator"); ProvincialCoordinator coordinator =new ProvincialCoordinator("Manitoba", 1000); // small population to make our % look better System.out.println(coordinator); //Create a clinic and register with the coordinator System.out.println(" Creating the Winnipeg clinic and registering with the coordinator"); VaccineClinic winnipegClinic = new VaccineClinic("Winnipeg Supersite"); coordinator.addClinic(winnipegClinic); //Give the province some doses to administer to its clinics: System.out.println("The province receives 4 vaccines to distribute to its clinics"); coordinator.distributeVaccinesToClinics(4); System.out.println(coordinator);

//Create annother clinic and register with the coordinator System.out.println(" Creating the Brandon clinic and registering with the coordinator"); VaccineClinic brandonClinic = new VaccineClinic("Brandon Supersite"); coordinator.addClinic(brandonClinic); System.out.println(coordinator);

// Distributing some additional doses System.out.println(" Distributing 9 more doses to the clinics"); coordinator.distributeVaccinesToClinics(9); System.out.println(coordinator);

//Create a few people and vaccinate them at the different clinics HealthID id1, id2, id3, id4; Patient alice, bob, liqun, ananta; // Instantiate the ids and patients id1 = new HealthID(); alice = new Patient("Alice", 68, id1); id2 = new HealthID(alice.getHealthID().getFamilyNumber()); bob = new Patient("Bob", 70, id2); id3 = new HealthID(); id4 = new HealthID(); liqun = new Patient("Liqun", 25, id3); ananta = new Patient("Ananta", 35, id4);

//Schedule some of the patients System.out.println(" Scheduling some patients at the clinics"); winnipegClinic.schedulePatient(alice); winnipegClinic.schedulePatient(liqun); winnipegClinic.schedulePatient(bob); brandonClinic.schedulePatient(ananta); // Display the coordinator's data System.out.println(coordinator);

// Administer some doses System.out.println(" Administer available doses at each clinic:"); winnipegClinic.administerAvailableDoses(); brandonClinic.administerAvailableDoses();

System.out.println(coordinator); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!