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