/home/ffrigin/NetBeansProjects/CS1/src/chance/Die.java
 1 /*
 2 * Model a die in terms of two properties:
 3 * - order, the number of faces
 4 * - top, the value of the top face
 5  */
 6 package chance;
 7 
 8 /**
 9  *
10  * @author ffrigin
11  */
12 public class Die {
13 // THE INSTANCE VARIABLES (STATE)
14 
15     private int order;
16     private int top;
17 // THE CONSTRUCTORS
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 // THE METHODS (BEHAVIOR)
29 
30     public int top() {
31         return top;
32     }
33 
34     public void roll() {
35         top = (int) ((Math.random() * order) + 1);
36     }
37 }
38