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