作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我目前在学校学习 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).
我的问题是,我究竟应该在哪里创建每个患者(指定姓名和病情严重程度),有人可以帮助我(请解释一下,因为我想学习,我不要求直接代码或答案)优先级方面以及如何按到达时间优先考虑具有相同严重程度的患者?
在此先感谢大家的帮助或意见!
最佳答案
开始创建特定的 Controller ,如 FrontDeskController
,并在此类中创建方法,例如 register
/checkIn
、checkOut
。您将在此处插入/删除所有患者数据,并将所有数据收集到您认为适合您的情况的单个 Collection
中。
要对队列进行优先级排序,如果可以将要处理的 Collection
分开,那么您必须使用简单的排序算法进行排序,例如快速排序,并将排序数据传递给另一个集合 e.q Queue
,堆栈
。我认为这种方法很适合放在 ER
类中。
关于java - Java模拟医院(优先队列),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15469237/
如何在 Android 谷歌地图中显示附近的地点和地点详情,如 ATM、医院、餐馆等 这是我使用的链接: Showing nearby places & place details using Goo
我是一名优秀的程序员,十分优秀!