I am creating a c++ snakes and ladders game (no visuals). I want the game to have up to 5 or 6 players. For the snakes/ladders I am going to create a function which needs the dice roll and adds it to the score which will then decide if the player has landed on a snake or a ladder, is there any way I can get all players scores to be stored in the “score” variable in the switch statements without using multiple switch statements? So I basically want a switch statement which can accommodate all 1-6 players .   E.g p1 initially at 1 rolls a 4.  So their new score is 1+4=5, then the switch function checks for a ladder or snake. Then player 2 who's initially a 2 rolls a 5, so their new score is 2+5=7 then THE SAME switch function checks for a snake or ladder... And so on for all other players.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter8: Advanced Method Concepts
Section: Chapter Questions
Problem 4RQ
icon
Related questions
Question
100%

I am creating a c++ snakes and ladders game (no visuals).

I want the game to have up to 5 or 6 players. For the snakes/ladders I am going to create a function which needs the dice roll and adds it to the score which will then decide if the player has landed on a snake or a ladder, is there any way I can get all players scores to be stored in the “score” variable in the switch statements without using multiple switch statements? So I basically want a switch statement which can accommodate all 1-6 players .

 

E.g p1 initially at 1 rolls a 4. 

So their new score is 1+4=5, then the switch function checks for a ladder or snake. Then player 2 who's initially a 2 rolls a 5, so their new score is 2+5=7 then THE SAME switch function checks for a snake or ladder... And so on for all other players.

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Concept of pointer parameter
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,