Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

1.bed 修正注释 #35

wants to merge 1 commit into from

Conversation

WakeDoor
Copy link

@WakeDoor WakeDoor commented Feb 7, 2020

2.Hospital 新增急需病床统计数
3.MyPanel update before fillOval
4.Person update,隔离中仍需处理,dieMoment计算包括隔离状态

2.Hospital 新增急需病床统计数
3.MyPanel update before fillOval
4.Person update,隔离中仍需处理,dieMoment计算包括隔离状态
@WakeDoor
Copy link
Author

WakeDoor commented Feb 7, 2020

老哥,向你学习。我们这个项目参与者要么拉个微信群呀,你起个头。我微信是chayc00,可以加你么。

Copy link
Contributor

@GinRyan GinRyan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有两处代码存疑

bed.setEmpty(true);
beds.add(bed);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

老实说…… remove一遍再add一遍同一个实例,有什么确切的讲究吗?

@@ -223,6 +224,9 @@ public void update() {
if (bed == null) {

//没有床位了,报告需求床位数
if(Hospital.bedInNeed < PersonPool.getInstance().getPeopleSize(State.FREEZE)) {
Hospital.bedInNeed++;
}

Copy link
Contributor

@GinRyan GinRyan Feb 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需求床位变量这里存在一点问题。为什么要判断需求床位数量小于已冻结的收治患者人数?已经冻结状态下的确诊患者是有床位实例的引用的。在这里是无法继续从医院的床位中寻找空置床位收治患者给与床位引用。所以判断已经收治的数量无从谈起。另外这里不能直接 Hospital.bedInNeed++,update方法会在重绘整个画布时被调用,有多少人就会被调用多少次,所以我考虑这个方法中有很多状态修改的操作也存在疑虑。所以在这里我只加了注释,没有在这里添加实质性代码。

Copy link
Contributor

@GinRyan GinRyan Feb 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议修改这个值的方式不是在这里++。而是在每个Person实例中修改一个状态变量,并且获取时通过循环获取累加。虽然效率低,但是能保持这个值的正确性。

@WakeDoor
Copy link
Author

WakeDoor commented Feb 7, 2020 via email

@WakeDoor
Copy link
Author

WakeDoor commented Feb 7, 2020 via email

@GinRyan
Copy link
Contributor

GinRyan commented Feb 7, 2020

List是引用存储,而且形参也是引用传递,在函数传递的形参修改的就已经是List中的状态变量。所以实际上你remove一次又add一次的仅仅是一个引用,是没有必要这么做的。Map中的覆盖也是覆盖的引用而并非是数据覆盖。代码中所判断的bedInNeed是根据FREEZE状态判断的总数量,该属性是已经有床位的医院收治的患者。所以不能获得这个属性的人数判断。没有床位的总数去判断已收治数量存在逻辑问题。

归还过程其实就是改变一下Bed的状态而已。

@WakeDoor
Copy link
Author

WakeDoor commented Feb 7, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants