Using two dice, we can play a simple game having the following rules: • The game has two players. • After deciding who throws the dice first, the players each roll both dice. • The player rolling the...



Using two dice, we can play a simple game having the following rules:


• The game has two players.


• After deciding who throws the dice first, the players each roll both dice.


• The player rolling the highest total face value of the dice wins; if the two totals are equal, it is a draw.


• Two exceptional cases are possible:


• A pair of ones (snake eyes) loses, unless both players roll snake eyes, in which case the game is a draw.


• A matching pair (doubles) wins, unless both players roll doubles, in which case the highest score wins.


Define the classes Die and TwoDice, as described in Project 1 of Chapter 6. Then define a class DiceGame that uses an instance of TwoDice to play the dice game just described. One player should be the user of the program; the other player should be the computer. Include at least the following methods in DiceGame: giveDirections, play, and reportWinner.


Write a program that contains a main method to control the game. It should create an instance of DiceGame, interact with the user to decide which player rolls first, and invoke methods of DiceGame as necessary.



May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here