我目前在学校学习 ADT,为了完成一项任务,我必须在医院模拟急诊室。我目前的患者课程如下:
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);
}
}
}
我现在需要创建一个名为 ER() 的类...我必须实现的许多方法之一具有以下条件:
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).
我的问题是,我将在哪里创建每个患者(指定姓名和病情严重程度)并且有人可以帮助我(请解释因为我想学习,我不要求直接代码或答案)优先方面以及如何优先考虑患者到达时间的严重程度相同?
提前感谢大家的帮助或输入!