1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
package bjc.utils.dice; import java.util.Random; public class Die { private static Random rng = new Random(); private int nSides; public Die(int nSides) { this.nSides = nSides; } public int roll() { return rng.nextInt(nSides + 1); } }