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