/** * A class to model a Pair of Dice * * @author Anthony Larrain */ public class PairOfDice{ private int die1; private int die2; /** * Generates two random integers in the interval [1,6] * @return the sum of the two generated integers. */ public int roll(){ die1 = (int) (Math.random() * 6 + 1); die2 = (int) (Math.random() * 6 + 1); return die1 + die2; } /** * Returns the previous roll. * @return The result of the previous roll * */ public int result(){ return die1 + die2; } /** * Returns the face of die1 * @return the face of die1 * */ public int getDie1() { return die1; } /** * Returns the face of die2 * @return the face of die2 */ public int getDie2(){ return die2; } /** * @return the face of die1 and die2 */ public String toString(){ return "Die1 is " + die1 + " Die2 is " + die2; } }