/** * Dice2Test.java * * * Created: Thu Feb 13 11:24:22 2003 * * @author M. Hoffmann * @author C. Kissig * @version 1.0 */ public class Dice2Test{ public static void main(String[] args){ // create three identifier for instances of the dice class Dice2 d4,d6,d20; // create three instances of the dice class d4 = new Dice2(4); d6 = new Dice2(6); d20 = new Dice2(20); // roll all three instances d4.reroll(); d6.reroll(); d20.reroll(); // build and store the sum of all three dice int sum = d4.getValue() + d6.getValue() + d20.getValue(); // display all dice d4.simpleDisplay(); d6.simpleDisplay(); d20.simpleDisplay(); // print out the sum of all three dice int avg = ( 4 + 6 + 20 ) / 2; if(sum > avg ) { System.out.println("The sum of all dice is above average"); } else { System.out.println("The sum of all dice is equal to or below average"); } } } // PlayWithDice