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