Question: Using the Box class you developed in the previous assignment, complete the implementation of the game. To recap game play from the previous assignment...
Using the Box class you developed in the previous assignment, complete the implementation of the game.
To recap game play from the previous assignment...
In this game Shut the Box there is a box that contains tiles numbered through with all tiles in the up position. In each round of the game the player rolls a pair of dice, unless the sum of the numbers on the upfacing tiles total or less in which case the player rolls a single die. After rolling the dice or die the player chooses one, two, or three of the upfacing tiles totaling the same number as the roll of the dice to move to the "down" position. The player continues until either all the tiles are in the down position, or there is no combination of upfacing tiles that total the roll of the dice. The player's score is the total of the upfacing tiles at the end of the game, with the goal being the lowest score possible. A perfect score is zero."
You will also need the Dice class.
Your program should play a single game, which consists of multiple rounds or rolls of the dice With each round, display the contents of the box, roll and display the dice or die then prompt for three tiles to close. Game play should continue in this manner until either all tiles are in the down position or the player enters three zero's for input.
The input for each round is three integers. You should validate that each integer is in the range through and no two nonzero input values are the same. Accoeding to the rules of the game, no input should be a downfacing tile, however if your Box class is implemented as described in part the Box object will handle that part of the validation.
Notice that when the sum of the tiles in the box totals or less, you need to switch to using a single die rather than two dice. You might consider declaring your Dice variable with two dice:
Dice dice;
Then within your game input loop once you detect that your box totals or less, you can overwrite the dice variable with a single die:
dice Dice;
Here is a sample run of the program:
Let's play Shut the Box
Box:
Dice:
Tiles:
Box:
Dice:
Tiles:
Tile selection is not valid. Try again.
Tiles:
Box:
Dice:
Tiles:
Tile selection is not valid. Try again.
Tiles:
Box:
Dice:
Tiles:
Box:
Dice:
Tiles:
Box:
Dice:
Tiles:
Box:
Score:
In this sample, the only user input is following the Tiles: prompt
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
