我目前在学校学习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).
我的问题是,我将在何处创建每位患者(指定名称和病情严重程度),并且有人可以帮助我(请解释因为我想学习,我不要求直接代码或答案)优先级方面以及如何根据到达时间确定具有相同严重程度的患者的优先次序?
提前感谢您的帮助或输入所有人!
答案 0 :(得分:1)
首先创建特定的控制器,例如FrontDeskController
,并在此类中创建方法,例如register
/ checkIn
,checkOut
。您将在此处插入/删除所有患者数据并收集您认为适合您案例的单Collection
中的所有数据。
要优先排序队列,如果可能将您要处理的Collection
分开,那么您必须使用简单的排序算法排序,例如快速排序,并将排序数据传递给另一个集合eq Queue
,{{1 }}。我认为这种方法很适合Stack
Class。