Answered step by step
Verified Expert Solution
Question
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 Step 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