PairOfDice - public int roll () { value1 = die1.roll();...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************************** // PairOfDice.java Author: Lewis and Loftus // // Solution to Programming Project 4.3 //******************************************************************** / public class PairOfDice { private Die die1, die2; private int value1, value2, total; //----------------------------------------------------------------- // Creates two six-sided Die objects, both with an initial // face value of one. //----------------------------------------------------------------- public PairOfDice () { die1 = new Die(); die2 = new Die(); value1 = 1; value2 = 1; total = value1 + value2; } //----------------------------------------------------------------- // Rolls both dice and returns the combined result. //-----------------------------------------------------------------
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: public int roll () { value1 = die1.roll(); value2 = die2.roll(); total = value1 + value2; return total; } //-----------------------------------------------------------------// Returns the current combined dice total. //-----------------------------------------------------------------public int getTotal () { return total; } //-----------------------------------------------------------------// Returns the current value of the first die. //-----------------------------------------------------------------public int getDie1 () { return value1; } //-----------------------------------------------------------------// Returns the current value of the second die. //-----------------------------------------------------------------public int getDie2 () { return value2; } }...
View Full Document

This note was uploaded on 05/17/2011 for the course COP 3530 taught by Professor Davis during the Spring '08 term at University of Florida.

Page1 / 2

PairOfDice - public int roll () { value1 = die1.roll();...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online