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