Consider the classes Die and TwoDice, as described in Project 1 of Chapter 6, and assume that they are defined. Suppose a class DiceGame uses an instance of TwoDice to play the following dice game:...


Consider the classes Die and TwoDice, as described in Project 1 of Chapter 6, and assume that they are defined. Suppose a class DiceGame uses an instance of TwoDice to play the following dice game: You roll two dice and check the sum of the values shown on their upper faces. If the sum is


• 7 or 11, you win.


• 2, 3, or 12, you lose.


• Any other value—4, 5, 6, 8, 9, or 10—you retain this value while another player rolls the dice.


Write a method rollTwoDice for DiceGame. This method should roll two dice and return 0 for a losing roll, 1 for a winning roll, and the value rolled for any other outcome.



May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here