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