-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomSimulator.java
More file actions
50 lines (32 loc) · 891 Bytes
/
RandomSimulator.java
File metadata and controls
50 lines (32 loc) · 891 Bytes
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
import java.util.Random;
public class RandomSimulator {
// This is for generate the probabilities to meet requirements
//Using Random Seed
public static boolean IsBreakDown(int n) {
Random rand = new Random();
double seed = rand.nextDouble() * (double) n;
if (seed <= (double) n * 0.3) {
return true;
}
return false;
}
public static boolean IsAccident(int n) {
Random rand = new Random();
double seed = rand.nextDouble() * (double) n;
if (seed <= (double) n * 0.1) {
return true;
}
return false;
}
public static int getTrafficCondition(int n) {
Random rand = new Random();
double seed = rand.nextDouble() * (double) n;
if (seed <= (double) n * 0.1) {
return 2;
} else if (seed > (double) n * 0.1 && seed <= (double) n * 0.35) {
return 1;
} else {
return 0;
}
}
}