Reputation: 287
Im currently learning ADT's in school and for an assignment I have to simulate an ER in a hospital. I currently have my patient class as follows:
public class Patient implements Comparable<Patient>{
private String name;
private int condition;
public Patient( String n, int c ){
this.name = name;
this.condition = condition;
}
public String toString(){
return name;
}
public int boundary(int condition) {
if (condition > 17){
return 17;
}
else if (condition < 1) {
return 1;
}
return condition;
}
public int compareTo( Patient other ) {
if( this.condition < that.condition ) {
return -1;
}
else if( this.condition > that.condition ) {
return +1;
}
else {
return this.name.compareTo(that.name);
}
}
}
And I need to now make a class called ER()... One of many methods i have to implement have the conditions as follows:
public void addPatient(String name, int severity, Date time)
// Purpose: adds a person to the waiting list in the emergency
// room.
// Preconditions: name is not null
// severity is an integer in the range [1,17]
// time is the current time
// Postconditions: the person is added to the emergency room
// waiting list. The "priority" in the list is
// based on severity (1 being least important and
// 17 being most important) first and for patients
// with equal severity, based on time (FIFO).
My question is, where exactly would I create each patient (assign name and condition severity) and could someone help me with (please explain cuz i wanna learn, im not asking for direct code or answers) the prioritizing aspect and how to prioritize patients with same severity by time of arrival?
Thanks in advance for any help or input everyone!
Upvotes: 3
Views: 4085
Reputation: 2596
Start with creating specific controller like FrontDeskController
, and in this class create method e.g register
/checkIn
, checkOut
. You will insert/remove all patients data here and collect all data in single Collection
which you think its suitable for your case.
To prioritizing queue, if it possible separate the Collection
you want to process, so you must sort with simple sort algorithm e.g quicksort and pass the sort data to another collection e.q Queue
, Stack
. i think this method good to be in ER
Class.
Upvotes: 1