Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ Part D: The Game 35% -28% output +7% code] In Part D, you will make a simple game using the modules from Parts A,

image text in transcribed
c++
Part D: The Game 35% -28% output +7% code] In Part D, you will make a simple game using the modules from Parts A, B and C. The game will consist of a main function in its own file named Main.cpp 1. Put #includes for the and , you will also need the line using namespace std; . Reminder: Put #pragma once at the top of every header (..) file. Reminder: Do not put #pragma once in any source (.cpp) file. Reminder: Never #include any source (cop) file into any other file. 2. Add a main function. It should start by initializing the dice module using one of your functions. Then it should declare variable of the Board (which is actually a 2D array of Ints defined in step B2 to be the game board and initialize it using another one of your functions. 3. Define a constant with the value for the number of players Declare a 1D array for the money that the players have and initialize its two clements to 0. After all the initialization is done, print a message to welcome the players to the game. . Note: We will refer to the two players as Player and Player L. 4. Add a main loop to your main function. We will refer to as the main fee. It can be written as le loop do The main loop is a loop that will run continually until the program terminates. Each time through the loop, print -> - to prompt the user and then reada line of user input using getline. If the input is ever the loop should end. Hint: The getline function takes two parameters, the input stream and the string to set. To read a line of console input into a variable named line, the syntax would be getline (cin, line) Note: We will fill in the contents of the main loop below. . For your information: Most interactive programs have a main loop. In a graphical program, it is often called an event loop and checks for input events such as mouse movement and keystrokes. 5. After the main loop, print out how much money each player has the message should include the player number and the money value with a dollar sign Then print a closing message. The remainder of the steps refer to the contents of the main loop 6. Declare a variable outside the main loop to keep track of the current player number and initialize it to 0. At the top of the loop, print "Player X's turn". where X is the current player number. At the bottom of the main loop (after getting user input), increment the current player. Then, if the number is too high, reset it to 0. 7. Before printing whose turn it is print the board using one of your functions. 8. After printing whose turn it is, get four dice rolls, two for the tow and two for the column. You will need to call one of your functions four times and save the results in four variables. At calling the function for times print the results out using another one of your functions Calculate the row and column of the cell and then print "Rolled cell: followed by the cell name. Use the two functions from the Boardsize module when printing the cell name. . Example: If the values rolled were 0, 1, 2 and 3, the output would be Row Column 101111 Rolled cell: 85 Determine how much money was in the cell using the boardGetAt function. Increase the current player's money by that amount Remove the money from the board, using a function to set it to 0. Print a message showing how much the player's money increased, such as: Money: 54 + $2 - $6 Part D: The Game 35% -28% output +7% code] In Part D, you will make a simple game using the modules from Parts A, B and C. The game will consist of a main function in its own file named Main.cpp 1. Put #includes for the and , you will also need the line using namespace std; . Reminder: Put #pragma once at the top of every header (..) file. Reminder: Do not put #pragma once in any source (.cpp) file. Reminder: Never #include any source (cop) file into any other file. 2. Add a main function. It should start by initializing the dice module using one of your functions. Then it should declare variable of the Board (which is actually a 2D array of Ints defined in step B2 to be the game board and initialize it using another one of your functions. 3. Define a constant with the value for the number of players Declare a 1D array for the money that the players have and initialize its two clements to 0. After all the initialization is done, print a message to welcome the players to the game. . Note: We will refer to the two players as Player and Player L. 4. Add a main loop to your main function. We will refer to as the main fee. It can be written as le loop do The main loop is a loop that will run continually until the program terminates. Each time through the loop, print -> - to prompt the user and then reada line of user input using getline. If the input is ever the loop should end. Hint: The getline function takes two parameters, the input stream and the string to set. To read a line of console input into a variable named line, the syntax would be getline (cin, line) Note: We will fill in the contents of the main loop below. . For your information: Most interactive programs have a main loop. In a graphical program, it is often called an event loop and checks for input events such as mouse movement and keystrokes. 5. After the main loop, print out how much money each player has the message should include the player number and the money value with a dollar sign Then print a closing message. The remainder of the steps refer to the contents of the main loop 6. Declare a variable outside the main loop to keep track of the current player number and initialize it to 0. At the top of the loop, print "Player X's turn". where X is the current player number. At the bottom of the main loop (after getting user input), increment the current player. Then, if the number is too high, reset it to 0. 7. Before printing whose turn it is print the board using one of your functions. 8. After printing whose turn it is, get four dice rolls, two for the tow and two for the column. You will need to call one of your functions four times and save the results in four variables. At calling the function for times print the results out using another one of your functions Calculate the row and column of the cell and then print "Rolled cell: followed by the cell name. Use the two functions from the Boardsize module when printing the cell name. . Example: If the values rolled were 0, 1, 2 and 3, the output would be Row Column 101111 Rolled cell: 85 Determine how much money was in the cell using the boardGetAt function. Increase the current player's money by that amount Remove the money from the board, using a function to set it to 0. Print a message showing how much the player's money increased, such as: Money: 54 + $2 - $6

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions