Die.java
1    package chance;
2    
3    public class Die {
4    
5        //Instance Variables
6        private int order;
7        private int top;
8    
9        //Constructors
10       public Die() {
11           order = 6;
12           top = (int) ((Math.random() * 6) + 1);
13       }
14   
15       public Die(int nrOfSides) {
16           order = nrOfSides;
17           top = (int) ((Math.random() * nrOfSides) + 1);
18       }
19   
20       //Methods
21       public int top() {
22           return top;
23       }
24   
25       public void roll() {
26           top = (int) ((Math.random() * order) + 1);
27       }
28   }
29