1 package chance; 2 3 public class Die { 4 5 //THE INSTANCE VARIABLES 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 public Die (int nrOfSides){ 17 order = nrOfSides; 18 top = (int) ((Math.random ()*nrOfSides)+1); 19 } 20 21 //THE METHODS (BEHAVIOR) 22 23 public int top(){ 24 return top; 25 } 26 public void roll(){ 27 top = (int) ((Math.random ()*order)+1); 28 } 29 }