import objectdraw.*; import java.util.Random; // a simulation of rolling dice public class Dice extends FrameWindowController { private static int MAX_DIE_VALUE = 6; // an object that generates random numbers private Random generator; // the result of rolling the first die private int dieRoll1; // the result of rolling the second die private int dieRoll2; public void begin() { // create the generator of random numbers generator = new Random(); } // roll two dice, then print their sum to the terminal public void onMousePress(Location point) { // get a random value from 1 to 6 for each die value dieRoll1 = generator.nextInt(MAX_DIE_VALUE) + 1; dieRoll2 = generator.nextInt(MAX_DIE_VALUE) + 1; System.out.println("Dice sum is: " + (dieRoll1 + dieRoll2)); } }