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 public Die(int nrOfSides) { 15 order = nrOfSides; 16 top = (int) ((Math.random() * nrOfSides) + 1); 17 } 18 19 20 public int top() { 21 return top; 22 } 23 24 public void roll() { 25 top = (int) ( ( Math.random() * order ) + 1); 26 } 27 } 28 29 30