-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimulation.java
52 lines (47 loc) · 2.26 KB
/
Simulation.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import javax.crypto.Cipher;
import java.util.Scanner;
import java.util.Random;
public class Simulation {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Random random = new Random();
int timeCycleCount = 0;
GenerateSubjects s = new GenerateSubjects(Constants.logicConstants.subjectCount);
Subject[] subjects = s.getSubjects();
String flag = "";
System.out.println("Press enter to run simulation cycle (any other key to end simulation)");
flag = input.nextLine();
while (flag.equals("")) {
timeCycleCount++;
System.out.println(Constants.colorConstants.BLUE + "TIME CYCLE: " + timeCycleCount + Constants.colorConstants.RESET);
for (Subject sub : subjects) {
boolean isDrinking;
int d = random.nextInt(2);
if (d == 0) {
isDrinking = true;
} else {
isDrinking = false;
}
if (isDrinking) {
//GENERATE Blood Alcohol Content (BAC)
double BAC = random.nextInt(Constants.logicConstants.maximumBAC) / 100.0;
if (BAC >= Constants.logicConstants.legalBACLimit) {
System.out.println();
System.out.println(Constants.colorConstants.RED + sub.name + "'s BAC of " + Constants.colorConstants.BLUE + BAC + "%" + Constants.colorConstants.RED + " is above the legal limit! CALLING EMERGENCY CONTACTS" + Constants.colorConstants.RESET);
sub.printLocation();
if (BAC >= Constants.logicConstants.extremelyHighBAC) {
sub.printHelpfulTips();
}
sub.messageEmergencyContacts();
}
}
}
System.out.println();
System.out.println("Double tap enter to run new simulation cycle (any other key + enter to end simulation)");
flag = input.nextLine();
if (flag.equals(""))
input.nextLine();
}
System.out.println(Constants.colorConstants.GREEN + "Simulation finished!" + Constants.colorConstants.RESET);
}
}