Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help with the Box class code and this. Assignment needs to be in C + + . Using the Box class you developed
I need help with the Box class code and this. Assignment needs to be in C
Using the Box class you developed in the provious assignment, complete the implementation 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 totals 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 players 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 multple 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 of through and no two nonzero input values are the same. According to the rules of the game, no input should be a downfacing tile, however if you Box class is implemented as described in part the Box object will handle that part of the validation.
Note 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 overrite 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started