Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
Write a C++ program to play a game called space race Problem: Write a C++ program to play a game called Space Race. Assume this
Write a C++ program to play a game called space race
Problem: Write a C++ program to play a game called Space Race. Assume this game is played on a board with 80 squares. Your program should move your spaceship from the starting square (square 1 on Earth) to the ending square (square 80 on Jupiter). On each turn, you draw a card to determine the number of squares to move your spaccship until you land on exactly square 80. Card values are from 1 to 5. "Space Bonus moves exist at various on the board to enhance play. If your spaceship lands on a Bonus square, your spaceship immediately move forward to the indicated square. The beginning and ending locations of each are: Space Bonuses 6 - Mars Trail 10- Einstein Wormhole 35 Leavitt Pass 42 - Milky Way Gap 64 - Tyson Black Hole 20 24 40 52 75 If a move would take the spaceship beyond square 80, then the spaceship's position should not be changed. The spaceship must wait until the next turn to try to land exactly on square 80. The output should be a table with one line displayed for each turn indicating the move number, the spaceship's current position, the value of the card drawn, the spaceship's new position and if the spaceship landed on a "Space Bonus" square, the name of the square. A header for the table should be printed before the game begins. Processing: Your main function should do the following: 1. Declare any variables needed, set the players starting position to 1. 2. Call a function to display the beading for the table of players moves on each turn. 3. Use a loop that takes a turn for the player each time through the loop until the player reaches square 80 exactly. A player's turn involves calling three functions in the body of the loop. a. drawCard-"draws" a card and returns the card's value b. moveShip- given a card value from function draw Card, this function calculates the square on which the spaceship will land (i.e., moves" the player along the board). It passes back the new location for the spaceship and the name of the "Space Bonus square if the spaceship landed on one. c. display Move -displays a line for one turn showing the move number, current position, card number, new position and Space Bonus name, if any. main displayHeading drawCard moveShip displayMove Work on one function at a time. For each function decide what its parameter(s) should be: what data, if any, needs to be passed to the function; what results, if any, will the function return or pass back. Then write the function and Make sure these match in the required ways. Determine where
![image text in transcribed](https://s3.amazonaws.com/si.experts.images/answers/2024/08/66d2aae840c48_34366d2aae79a207.jpg)
![image text in transcribed](https://s3.amazonaws.com/si.experts.images/answers/2024/08/66d2aae91a501_34466d2aae875bf9.jpg)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
![blur-text-image](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-text-image.webp)
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
![blur-text-image](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-subtext-image.webp)
Step: 3
![blur-text-image](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-subtext-image.webp)
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started