Question: The Code should be in C++. Please help. Thank you!! This project is a variation of the dice game Pig . You may have built
The Code should be in C++. Please help. Thank you!!
This project is a variation of the dice game Pig. You may have built some variation of this game in Comptuer Science I. If you didn't, or to refresh your memory, here's a page that describes the game and some of its variations: https://www.wikiwand.com/en/Pig_(dice_game).
This is yet another variation of the game which incorporates the following rules:
During a player's turn, they may roll the dice up to three times. After three rolls, or the player to chooses to stop rolling sooner, play moves to the next player.
When a player rolls the dice, they choose the number of dice they will roll from one to five. (This gives a player the opportunity to score as many as 30 points on a single roll, but increases their chances of rolling a one and losing points.)
If on any roll there is a single one rolled among the dice, the player's turn is over and they lose the points for that turn (but retain any score accumulated on previous turns).
If on any roll there are two or more one's rolled among the dice, the payer's turn is over and their total score returns to zero.
The first player to score 100 wins the game.
Write a program that plays this game with two players. The flow of your program should be as follows:
Start with a welcome message.
Ask the number of players. Acceptable values are 2 through 4.
Ask for each player's name.
Rotate play among the players:
Announce the player's name
For at least once but no more than three times:
Ask for the number of dice to roll
If there are two or more one's, the player's turn is over and their total score goes to zero
Else if there is a single one, the player's turn is over and their score for this turn is zero
Else add the dice total to the player score for this turn
If not the third roll, and the turn is not over by virtue of rolling a one, ask if player wishes to roll again
Add the score for this turn (so long as no one's were rolled) to the player's total score
Play rotation continues until the first player reaches 100 points.
Use the Dice class that was developed during class. Use the version that supports a collection of dice. (Not included with the assignment, you will need to add it to the project.)
Build a class called Player (not a suggestion, but a requirement for this assignment). This class should encapsulate all the aspects of a single player in the game. It should have properties to include the player's name and total score. It should also include a play method to carry out the game play for a single turn. (This play method will use a Dice object.)
Your main function should take care of setting up the players and controlling the turns among players.
Focus on building your Player class first. Test the play method and get it working before moving on the main function.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
