-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInput.java
More file actions
37 lines (29 loc) · 727 Bytes
/
Input.java
File metadata and controls
37 lines (29 loc) · 727 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
package enumStudy;
import java.util.Random;
public enum Input {
NICKEL(5), DIME(10), QUARTER(25), DOLLAR(100),
TOOTHPASTE(200), CHIPS(75), SODA(100), SOAP(50),
ABORT_TRANSACTION {
public int amount() {
throw new RuntimeException("ABORT .amount");
}
},
STOP {
public int amount() {
throw new RuntimeException("SHUT_DOMN .amount");
}
};
int value;
private Input(int value) {
this.value = value;
}
Input() {
}
int amount() {
return value;
}
static Random random = new Random(47);
public static Input randomSelection() {
return values()[random.nextInt(values().length - 1)];
}
}