C++ code A simple version of snakes and ladder Implement a game that initially asks how many players will play the game. The game will then ask the  name of each player. The game is played as follows: 1. The game is played iteratively. In every iteration, every player takes turn to roll a dice. The face  value of dice is added to the total score of the player. 2. The first player to reach 100 score gets 1st position. The second player to reach 100 score gets  2 nd position. 3. When a player reaches 100, he no longer remains part of the play. If current score + face value is  greater than 100, then the player will retry in the next iteration, i.e., the score must exactly  become 100. 4. There are ladders at 20 and 60. If a player’s score becomes exactly 20, the score becomes 40. If  a player’s score is exactly 60, the score becomes 75. Similarly, there are snakes at 50 and 90. If a  player’s score is exactly 50, the score become 40. If a player’s score is exactly 90, the score  becomes 79. 5. When n-1 players have reached 100, the game ends and the position of all players that  participated in the game is displayed in ascending order.  6. During game play, some useful messages should be displayed, so that one can know what is  going on in the game, such as: Please enter the number of players: 2 Please enter the name of Player 1: ABC Please enter the name of Player 2: XYZ It is ABC’s turn, please enter any key to continue. ABC got 5. The total score of ABC is now 5. It is XYZ’s turn, please enter any key to continue. XYZ got 6. The total score of XYZ is now 6. It is ABC’s turn, please enter any key to continue. ABC got 3. The total score of ABC is now 8. . . . It is XYZ’s turn, please enter any key to continue. XYZ got 4. The total score of XYZ is 50. There is a snake at 50, so total score is now 40. Use queue for this problem. You can use the queue class available in STL. You can only use push,  pop, front, and empty functions of STL queue. Apart from queues, you cannot use any other data  structures including arrays in any way (not even for storing the record of players that have already  finished the game).

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

C++ code

A simple version of snakes and ladder
Implement a game that initially asks how many players will play the game. The game will then ask the 
name of each player. The game is played as follows:
1. The game is played iteratively. In every iteration, every player takes turn to roll a dice. The face 
value of dice is added to the total score of the player.
2. The first player to reach 100 score gets 1st position. The second player to reach 100 score gets 
2
nd position.
3. When a player reaches 100, he no longer remains part of the play. If current score + face value is 
greater than 100, then the player will retry in the next iteration, i.e., the score must exactly 
become 100.
4. There are ladders at 20 and 60. If a player’s score becomes exactly 20, the score becomes 40. If 
a player’s score is exactly 60, the score becomes 75. Similarly, there are snakes at 50 and 90. If a 
player’s score is exactly 50, the score become 40. If a player’s score is exactly 90, the score 
becomes 79.
5. When n-1 players have reached 100, the game ends and the position of all players that 
participated in the game is displayed in ascending order. 
6. During game play, some useful messages should be displayed, so that one can know what is 
going on in the game, such as:
Please enter the number of players: 2
Please enter the name of Player 1: ABC
Please enter the name of Player 2: XYZ
It is ABC’s turn, please enter any key to continue.
ABC got 5. The total score of ABC is now 5.
It is XYZ’s turn, please enter any key to continue.
XYZ got 6. The total score of XYZ is now 6.
It is ABC’s turn, please enter any key to continue.
ABC got 3. The total score of ABC is now 8.
.
.
.
It is XYZ’s turn, please enter any key to continue.
XYZ got 4. The total score of XYZ is 50. There is a snake at 50, so total score is now 40.
Use queue for this problem. You can use the queue class available in STL. You can only use push, 
pop, front, and empty functions of STL queue. Apart from queues, you cannot use any other data 
structures including arrays in any way (not even for storing the record of players that have already 
finished the game).

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education