-
Notifications
You must be signed in to change notification settings - Fork 573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.bed 修正注释 #35
base: master
Are you sure you want to change the base?
1.bed 修正注释 #35
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ public Bed(int x, int y) { | |
} | ||
|
||
/** | ||
* 是否占用了该床位 | ||
* 是否空闲 | ||
*/ | ||
private boolean isEmpty = true; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import javax.net.ssl.HostnameVerifier; | ||
import java.util.List; | ||
import java.util.Random; | ||
|
||
|
@@ -195,12 +196,12 @@ private void action() { | |
public void update() { | ||
//@TODO找时间改为状态机 | ||
|
||
if (state == State.FREEZE || state == State.DEATH) { | ||
return;//如果已经隔离或者死亡了,就不需要处理了 | ||
if (state == State.DEATH) { | ||
return;//如果已经死亡,就不需要处理了 | ||
} | ||
|
||
//处理已经确诊的感染者(即患者) | ||
if (state == State.CONFIRMED && dieMoment == 0) { | ||
if ((state == State.CONFIRMED || state == State.FREEZE) && dieMoment == 0) { | ||
|
||
int destiny = new Random().nextInt(10000) + 1;//幸运数字,[1,10000]随机数 | ||
if (1 <= destiny && destiny <= (int) (Constants.FATALITY_RATE * 10000)) { | ||
|
@@ -223,6 +224,9 @@ public void update() { | |
if (bed == null) { | ||
|
||
//没有床位了,报告需求床位数 | ||
if(Hospital.bedInNeed < PersonPool.getInstance().getPeopleSize(State.FREEZE)) { | ||
Hospital.bedInNeed++; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 需求床位变量这里存在一点问题。为什么要判断需求床位数量小于已冻结的收治患者人数?已经冻结状态下的确诊患者是有床位实例的引用的。在这里是无法继续从医院的床位中寻找空置床位收治患者给与床位引用。所以判断已经收治的数量无从谈起。另外这里不能直接 Hospital.bedInNeed++,update方法会在重绘整个画布时被调用,有多少人就会被调用多少次,所以我考虑这个方法中有很多状态修改的操作也存在疑虑。所以在这里我只加了注释,没有在这里添加实质性代码。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 建议修改这个值的方式不是在这里++。而是在每个Person实例中修改一个状态变量,并且获取时通过循环获取累加。虽然效率低,但是能保持这个值的正确性。 |
||
} else { | ||
//安置病人 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
老实说…… remove一遍再add一遍同一个实例,有什么确切的讲究吗?