-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDiseaseMap.java
More file actions
48 lines (44 loc) · 1.63 KB
/
DiseaseMap.java
File metadata and controls
48 lines (44 loc) · 1.63 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
/****************************************************************************
* Name: Andrew Hunt
*
* Compilation: javac DiseaseMap.java
* Dependencies: Std Lib
* Constructor: DiseaseMap(int students, int infected, int rate)
*
* Description: The DiseaseMap class enables users to map the progression of
* a disease using a rate of contraction.
* Next steps:
* - rates of cure
* - deaths
* - a way of testing the probability of exposure of
* a single student based on their activities (ex. STIs).
*
****************************************************************************/
public class DiseaseMap {
private int numStudents;
private int numInfected;
private int rateOfInfection; // % of uninfected students who will contract
// per cycle
// Create new DiseaseMap object
public DiseaseMap(int students, int infected, int rate) {
this.numStudents = students;
this.numInfected = infected;
this.rateOfInfection = rate;
}
// Get current percentageDiseased
public double getPercInfected() {
return (double) this.numInfected/this.numStudents*100;
}
// Progresses the map T cycles
public void progress(int T) {
for (int i = 0; i < T; i++) {
singleProgress();
System.out.println(i + " " + this.numInfected);
}
}
// Progresses the map one time cycle
private void singleProgress() {
int newlyInfected = rateOfInfection*(numStudents-numInfected)/100;
this.numInfected += newlyInfected;
}
}