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.
Keep all of your methods short and simple. In a properly-written object-oriented program, the work is distributed among many small methods, which call each other. There are no methods in this entire assignment that should require more than 12 lines of code, not counting comments, blank lines, or {} lines (and many of them need no more than 3).
Unless specified otherwise, all instance variables must be private, and all methods should be public. Also unless specified otherwise, there should be no println statements in your classes. Objects usually do not print anything, they only return String values from toString methods. The only exception in this assignment is displayPatientsWaiting() in VaccineClinic (Phase 2).
Testing Your Code
We have provided sample test files for each phase to help you verify that your code is working to the assignment specifications (e.g., correct method headers). These files are only starting points for testing your code. Part of developing your skills as a programmer is to think through additional important test cases and to write your own code to test these cases. The test files should give you a sense what this additional code could consist of.
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)
Hand in
Submit your four Java files (Patient.java, HealthID.java, VaccineClinic.java, ProvincialCoordinator.java). Do not submit .class or .java~ files! You do not need to submit the TestPhaseN.java files that were given to you. If you did not complete all three phases of the assignment, use the Comments field in UMLearn when you hand in the assignment to tell the marker which phases were completed, so that only the appropriate tests will be run. For example, if you say that you completed Phases 1-2, then the marker will compile your files and then run the automated tests for phases 1-2 only. If the appropriate test files do not compile and run, you will lose all of the marks for the test runs. The marker will not try to run anything else, and will not edit your files in any way. Make sure none of your files specify a package at the top!
Step 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