Question: class EmergencyFacility This class has the following instance variables: A Random variable randy A Priority Q ueue of type Patient called waitingQ An ArrayList of

class EmergencyFacility
This class has the following instance variables:
A Random variable randy
A Priority Q ueue of type Patient called waitingQ
An ArrayList of type Patient called processedPatients - may be instantiated in variable declaration or in
the constructor)
An array of type Doctor called doctors (remember this is an array, not an ArrayList))
A String variable facilityName
An int variable currentTime set to 0
It has a single constructor with three parameters: String name, int seed, int numDoctors
It simple sets facilityName to name (You can do this without calling a mutator)
It creates the waitingQ object using a new instance of PatientPriority as the parameter, ensuring
that waitingQ prioritizes according to PatientPriority rules
It creates a Random object called randy based on the seed
It calls createDoctors with numDoctors as the parameter
createDoctors has a single int parameter called numDoctors and a void return
It creates the doctors array with a length equal to the value of numDoctors
For each reference in the array it creates a Doctor (Remember that the Doctor constructor has no
parameters)
openEmergencyFacility has no parameters and a void returm
Note: This starts the clock at time 0 and revs for 10 minutes (i.e.0 currentT ime 10) of loading
up the line before the EmergencyFacility doors open and service begins. cwrentTime should have
a value of 10 when this is finished
for (current Time =0; current Time 10; current Time++)/ This simulates early arriving Patients
Do 10 times
Generate a random number of type int from 1 to 20(inclusive meaning all of 1
through 20 using randy) and use it below
if the random number is less than 8
Create and add an UrgentP atient to the waiting Q with the currentTime
else if the random number is less than 16
Create and add a SeverePatient to the waitingQ with the currentTime
else
Create and add a NominalPatient to the waiting Q with the currentTime
operateEmergencyFacility has a parameter int called durationFor.Arriving and a void retum
Create an int variable end.Arrivals Time and set it equal to the sum of the currentTime and
durationForArriving
Create any necessary temporary variables for this method i.e. tempPatient
while the size of processedPatients does not equal the Patient idCounter or the currentTime is less than
the endArrivals Time (note: all arrivals get processed this way)
if the currentTime is less than the endArrivalsTime /This simulates arriving Patients until the
office doors close
Do 6 times
Generate a random number of type int from 1 to 20(inclusive meaning all of 1
through 20 using randy) and use it below
if the random number is less than 7Create and add an UrgentPatient to the waitingQ with the current Time
else if the random number is less than 14
Create and add an SeverePatient to the waitingQ with the current Time
else
Create and add an NominalPatient to the waitingQ with the current Time
End of the do loop
/Now check on the busy Doctors
for each Doctor referenced in the doctors array
if the Doctor isn't free (i.e. getlsFree returns false)
Call decrementTimeRemainingForExam() for this Doctor
if the timeRemainingForExam for this Doctor is 0
Retrieve the reference to the Patient currently assigned to this
Doctor (use a tempPatient variable to capture the reference and the
method getAssignedPatient())
Add that tempPatient to the processedPatients ArrayList
Call setTotalTimeAtEmergencyFacility for this tempPatient with the
currentTime
Call removeAssignedPatient() for this Doctor
//Now Assign Patients to free Doctors. Note: this section must come after the above section
For each Doctor referenced in the doctors array
if isFree is true for the Doctor (ie. getisFree returns true) and the waiting Q is not
empty
Remove a Patient from the waitingQ (use a tempPatient variable to capture
the reference)
Call setDoctorStart Time for tempPatient with the currentTime
For this Doctor call setAssignedPatient with a reference tempPatient just
removed from the waitingQ
Use randy to help get a number from 10 to 25 minutes (inclusive) calling it
examDuration
Call setExamDuration for the tempPatient with examDuration as the
parameter
Call setTimeRemainingForExam for this Doctor with this examDuration as
the value the parameter
Increment currentTime by 1. Note this happens inside the while loop just before looping
End the while (put in here for clarity of description only
generateEmergencyF acilityResults has a String parameter representing the physical output file and
retums a void (remember the throws IOException)
This method should write data to the output file. efoutput.tst is a sample based on following my
instructions and the interactive input below.
First create a PrintWriter based on the physical o
class EmergencyFacility This class has the

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 Finance Questions!