/home/ffrigin/NetBeansProjects/CS1/src/chance/Die.java |
1
2
3
4
5
6 package chance;
7
8
9
10 @author
11
12 public class Die {
13
14
15 private int order;
16 private int top;
17
18
19 public Die() {
20 order = 6;
21 top = (int) ((Math.random() * 6) + 1);
22 }
23
24 public Die(int nrOfSides) {
25 order = nrOfSides;
26 top = (int) ((Math.random() * nrOfSides) + 1);
27 }
28
29
30 public int top() {
31 return top;
32 }
33
34 public void roll() {
35 top = (int) ((Math.random() * order) + 1);
36 }
37 }
38