Answered step by step
Verified Expert Solution
Link Copied!

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 9 tiles numbered 1 through 9 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 up-facing tiles totals 6 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 up-facing 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 up-facing tiles that total the roll of the dice. The players score is the total of the up-facing 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 0 through 9, and no two non-zero input values are the same. According to the rules of the game, no input should be a down-facing tile, however if you Box class is implemented as described in part 1 the Box object will handle that part of the validation.
Note that when the sum of the tiles in the box totals 6 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(2);
Then, within your game input loop once you detect that your box totals 6 or less, you can overrite the dice variable with a single die:
dice = Dice(1);
Here is a sample run of the program:
Let's play Shut The Box
Box: 123456789
Dice: 6-3
Tiles: 900
Box: 12345678*
Dice: 5-6
Tiles: 833
Tile selection is not valid. Try again.
Tiles: 830
Box: 12*4567**
Dice: 1-3
Tiles: 130
Tile selection is not valid. Try again.
Tiles: 400
Box: 12**567**
Dice: 2-1
Tiles: 120
Box: ****567**
Dice: 3-2
Tiles: 500
Box: *****67**
Dice: 5-6
Tiles: 000
Box: *****67**
Score: 13
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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions