/** * DieTester.java * * @author Jeff Ondich * @version 9/27/05 * * The main() method of this class tests the Die class. */ import java.awt.*; class DieTester { public static void main( String[] args ) { // Prepare a canvas. Canvas canvas = new Canvas( "Die test" ); canvas.setSize( 700, 700 ); canvas.setVisible( true ); // Instantiate a Die. Die d = new Die( 1, 100, Color.green, Color.black ); // Run through all six values and draw them on screen // in handy viewing locations. d.setValue( 1 ); d.draw( canvas, 100, 100 ); d.setValue( 2 ); d.draw( canvas, 300, 100 ); d.setValue( 3 ); d.draw( canvas, 100, 300 ); d.setValue( 4 ); d.draw( canvas, 300, 300 ); d.setValue( 5 ); d.draw( canvas, 100, 500 ); d.setValue( 6 ); d.draw( canvas, 300, 500 ); // Roll the Die and draw it in the upper right of the canvas. // As a small debugging aid, print the value of the rolled die in // the terminal. d.roll(); System.out.println( "The value of the rolled die is " + d.getValue() + "." ); d.draw( canvas, 500, 100 ); } }