-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInfections.java
More file actions
78 lines (67 loc) · 2.24 KB
/
Infections.java
File metadata and controls
78 lines (67 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package oop.flu;
/**
* Created by Arnaud on 23/11/2015.
*/
public class Infections {
private boolean infected;
private int time;
public Infections(LivingBeing that) {
this.time = that.getTime();
this.infected = that.isInfected();
Infected(that);
}
public void Infected(LivingBeing thing) {
int nbRand = (int) (Math.random() * ((100)));
if (thing.isNew() == true){
thing.setNew(false);
}
else if ((this.infected = true) && (nbRand<20) &&(time>=2) && (time<=5)){
thing.setDisease(Disease.H1N1);
thing.setState(State.DEAD);
thing.setTime(0);
thing.setInfected(false);
thing.setDead(true);
}
else if (this.infected = true) {
switch (time) {
case 0: //passe au stade de SICK
thing.setDisease(Disease.H1N1);
thing.setState(State.SICK);
thing.setTime(time + 1);
thing.setInfected(true);
break;
case 1:
thing.setTime(time + 1);
break;
case 2: //passe au stade de CONTAGIOUS
thing.setDisease(Disease.H1N1);
thing.setState(State.CONTAGIOUS);
thing.setTime(time + 1);
thing.setInfected(true);
break;
case 3:
thing.setTime(time + 1);
break;
case 4:
thing.setTime(time + 1);
break;
case 5: //passe au stade de RECOVERING
thing.setState(State.RECOVERING);
thing.setTime(time + 1);
thing.setInfected(true);
break;
case 6:
thing.setTime(time + 1);
break;
case 7:
thing.setTime(time + 1);
break;
case 8:
thing.setState(State.IMUN);
thing.setDead(true);
thing.setInfected(false);
break;
}
}
}
}