-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPerson.java
37 lines (31 loc) · 875 Bytes
/
Person.java
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
import java.util.*;
public class Person {
String status;
double infectionRate;
double recoveryRate;
Random rand = new Random();
//Constructor
public Person(String status, double infectionRate, double recoveryRate){
this.status = status;
this.recoveryRate = recoveryRate;
this.infectionRate = infectionRate;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public void recover() {
double randomProb = rand.nextDouble();
if (status.equals("I") && randomProb <= recoveryRate) {
status = "R";
}
}
public void infect() {
double randomProb = rand.nextDouble();
if (status.equals("S") && randomProb <= infectionRate) {
status = "I";
}
}
}