Post Lab 8: Rolling a Pair of Dice
Due Friday, November 5, 2004
In this assignment you will write a PairOfDice class and then use
it in a program with a loop.
The PairOfDice class should have the following instance data: two
Die objects. Use the class Die.java from your
textbook. The methods in the PairOfDice class should be:
- a constructor with no parameters - the constructor will instantiate
each Die object.
- a method roll that rolls each die and returns the sum of
the face values. The method should have
no parameter. (NOTE: You need to use methods in the Die here and in
other methods.)
- a method isDoubles that returns true if the face values on
the two dice are the same ("doubles") and false otherwise.
- a toString method that returns the PairOfDice object as a string in
the following format (assuming the first die is a 2 and the second a 5):
[ 2 : 5 ]
- a method getTotalRoll that returns the total of the
face values on the two dice.
Write a program PlayGame that does the following:
Hand In:
- Hard copy of PairOfDice.java and PlayGame.java.
- Tar you post lab directory that contains all of your files and email
it to your instructor with the subject cs120 post8.