import java.util.Random; // Warn Java we want to use Random import java.util.ArrayList; /** * The Die class models a die of the sort you'd roll: It * can be created with as many sides as you wish, and has * a roll method that returns an appropriate random result. * * We're now updating our old friend the Die class to keep * track of how MANY of each possible values it has rolled. */ public class Die { private int numSides; // How many sides does my die have? private Random rng; // Will hold our random number generator object private int[] history; // Track how many 1's, 2's, etc. have been rolled // I wrote an ArrayList-based version of the history as well, to show // that it would be more difficult to take that route. private ArrayList histAL = new ArrayList(); /** * Constructor for objects of class Die. The default constructor * (this one, since it takes no parameters) will create a six-sided * die. */ public Die() { numSides = 6; rng = new Random(); history = new int[6]; // If we used an ArrayList we'd have to add a bunch of zeroes for(int i=0; i