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