Question: C++ USING CLASSES (NEED A HEADER FILE AND PROGRAM) Use the classes you have written in the lab (Die and Pair of Dice) to design

C++ USING CLASSES (NEED A HEADER FILE AND PROGRAM)

Use the classes you have written in the lab (Die and Pair of Dice) to design and implement the MyGame class. This class represents a game where the user computes against the computer. The goal is to get 100 points before your opponent. The game rules are as follows:

On each turn, the current player rolls a pair of dice repeatedly until 1 is rolled (on either dice) or the player chooses to hold. If 1 is rolled, all of the points rolled (total of dice faces) during that turn are added to the score except when 1 was rolled. If the user chooses to hold, all the points during that turn are added to the score.

If 1 is rolled on both dice, that players turn is over with no points earned, and the dice control moves to the other player.

Scoring Examples:

Elma rolls a (3, 3) and decides to continue. She then chooses to roll seven more times {(6,2), (6, 4), (5, 6), (4, 3), (5, 2), (6, 6), (1,1)}. Because she rolled (1, 1), her turn ends and she earns 0 points.

Craig rolls (6, 2) and decides to continue. He then chooses to roll four more times {(3, 3), (4, 2), (5, 2), (6, 6)} and decides to hold. He earns 39 points.

Dana rolls (6, 2) and decides to continue. She then chooses to roll four more times {(2, 3), (3, 2), (5, 5), (6, 1)}. Because she rolled (6, 1), her turn ends and she earns 28 points.

Implement the game such that the computer player always holds after accumulating 20 or more points in any given round, and once a player scores >= 100 points, the player wins (without waiting for a hold, or 1 to be rolled for the points to be added).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!