Die.java
1    package chance;
2    
3    /* 
4     
5    Model a die in terms of two properties: 
6    - Order, the number of face 
7    - Top, the value of the top face 
8     
9     */
10   
11   public class Die {
12   
13       private int order;
14       private int top;
15   
16       public Die() {
17           order = 6;
18           top = (int) ( (Math.random() * 6 ) + 1);
19       }
20   
21       public Die(int nrOfSides) {
22           order = nrOfSides;
23           top = (int) ( ( Math.random() * nrOfSides ) + 1);
24       }
25   
26       //the methods
27   
28       public int top() {
29           return top;
30       }
31   
32       public void roll() {
33           top = (int) ( ( Math.random() * order ) + 1 );
34       }
35   
36   }
37   
38   
39