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