1 /* 2 Model a die in terms of two properties; 3 order, the number of faces 4 top, the value of the top face 5 */ 6 7 package Chance; 8 9 public class Die { 10 //The Instance Variables 11 12 private int order; 13 private int top; 14 15 //The constructors 16 17 public Die() { 18 order = 6; 19 top = (int) ((Math.random()*6) + 1 ); 20 21 22 } 23 24 public Die(int nrOfSides){ 25 order= nrOfSides; 26 top = (int) ((Math.random() * order)+ 1); 27 28 } 29 30 //The Methods(Behavior) 31 public int top(){ 32 return top; 33 34 } 35 36 public void roll(){ 37 top = (int)((Math.random() * order) +1); 38 39 } 40 } 41