/home/sjenks/NetBeansProjects/CS1/src/chance/Die.java
 1 /*
 2  * Model a die in terms of two properties: 
 3  * - order, the number fo faces 
 4  * - top, the value of the top face
 5  */
 6 package chance;
 7 
 8 /**
 9  *
10  * @author sjenks
11  */
12 public class Die {
13 
14     //THE INSTANCE VARIABLES (STATE)
15     
16         private int order;
17         private int top;
18         
19         //THE CONSTRUCTORS
20         public Die(){
21             order = 6;
22             top = (int) ((Math.random() * 6 ) + 1);
23         }
24         
25         public Die(int nrOfSides){
26             order= nrOfSides;
27             top= (int) ( ( Math.random() + nrOfSides ) + 1);
28         }
29         
30         //THE METHODS (BEHAVIOR)
31         
32         public int top(){
33             return top;
34             
35         }
36         public void roll(){
37             top = (int ) ( ( Math.random() * order) + 1);
38             
39         }
40     
41     /**
42      * @param args the command line arguments
43      */
44     public static void main(String[] args) {
45         // TODO code application logic here
46     }
47     
48 }
49