Answered step by step
Verified Expert Solution
Question
1 Approved Answer
solution should be in c++ Snakes and Ladders is a simple game in which each player takes a turn to roll a die and move
solution should be in c++
Snakes and Ladders is a simple game in which each player takes a turn to roll a die and move their counter by the number shown on the die. If a player's counter happens to land on the bottom of a ladder they move up the ladder to the square at the top of the ladder; if a player's counter lands on the head of a snake they move down the snake to the square at the end of the snake's tail. All the players' counters start on square one and each player rolls the die in turn and moves their counter. The game ends when one of the players' counters lands directly on, or would move beyond, the finishing square (square 36). The game board is illustrated below in Figure 1. Note, only a single snake or ladder can terminate on any given square. Figure 1: Snakes and Ladders Board Your task is to create a program which simulates the game of Snakes and Ladders, and produces an output similar to that shown in Listing 2. The output will not be exactly the same because you need to simulate the roll of the die which produces a random value for each roll. You are required to provide the complete code for simulating the game. Your solution must make appropriate use of classes and objects, and conform to good coding principles. Listing 2: Console output from Snakes and Ladders simulation. From the output it is evident that the players are moving according to the rules of the game. For example, line 3 of the output shows that player 3 has climbed a ladder, while line 7 of the output shows that player 1 has slid down a snakeStep 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