- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDifficulty.java
More file actions
Latest commit
43 lines (33 loc) · 847 Bytes
/
Copy pathDifficulty.java
File metadata and controls
43 lines (33 loc) · 847 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
importjava.util.Random;
publicclassDifficulty {
publicenumLevel { EASY, MEDIUM, HARD };
publicintmin;
publicintmax;
publicLevellevel;
privateDifficulty(intmin,intmax, Levellevel) {
this.min = min;
this.max = max;
this.level = level;
}
publicstaticDifficultygetEasyDifficulty() {
returnnewDifficulty(0, 101, Level.EASY);
}
publicstaticDifficultygetMediumDifficulty() {
returnnewDifficulty(0, 501, Level.MEDIUM);
}
publicstaticDifficultygetHardDifficulty() {
returnnewDifficulty(-250, 501, Level.HARD);
}
publicintgetStartValue(Randomrand) {
switch (level) {
caseEASY:
returnrand.nextInt(10) + 1;
caseMEDIUM:
returnrand.nextInt(50) + 1;
caseHARD:
returnrand.nextInt(101) - 50;
default:
thrownewRuntimeException("Invalid Difficulty");
}
}
}