/home/jfernan6/NetBeansProjects/CSX/src/chance/Die.java
 1 /*
 2  * Model a die in terms of two properties:
 3  * - order, the number of faces
 4  * - top, the valuee of the top of face
 5  */
 6 package chance;
 7 
 8 /**
 9  *
10  * @author jfernan6
11  */
12 public class Die {
13     
14     //The Instace Variables (STATE)
15     private int order;
16     private int top;
17     
18     // The Constructors
19     
20     public Die() {
21         order = 6;
22         top = (int) ((Math.random() * 6) + 1);
23         
24     }
25     
26     public Die ( int nrOfSides) {
27         order = nrOfSides;
28         top = (int) ((Math.random() * nrOfSides) + 1);
29     }
30     
31     // THE ME THODS (BEHAVIOR)
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     
43     
44     
45     
46     
47     
48     
49     
50     
51     
52     
53     
54 }
55