Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The main purpose of this assignment is to give you practice using two-dimensional arrays, including passing two-dimensional arrays to functions. For Part A, you will

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

The main purpose of this assignment is to give you practice using two-dimensional arrays, including passing two-dimensional arrays to functions. For Part A, you will add constants and functions relating to the size of the game board. For Part B, you will add functions to handle the game board itself. For Part C, you will add constants and functions related to simulated dice. For Part D, you will use the constants and functions from Parts A, B, and C to write the game program. Then, for Part E, you will improve the display of the game board. Another purpose of this assignment is to familiarize you with multi-file programs. To keep the assignment from getting to be too long, the files are small and the functions are mostly short. Many functions only contain a single line of code. Warning: The test programs used in this course sometimes capture and tests the output from the cout buffer. Therefore, you must use cout to print your output. If you print it in some other way, (e.g. using printf or cerr), the test program will not see it. Then you will get a mark of zero for that portion of the assignment The Game Board The game board will be represented as a 2-dimensional array. It is 7 x 7 cells in size. The elements of the array will store the amount of money in the different grid cells. The grid rows will be named using the (uppercase) letters 'A' to 'G', and the grid columns will be named using the digits 'O' to '6'. Thus, each cell will have a unique name such as A2 (row 0, column 2) or 26 (row 4, column 6). The cells on the board will start with more or less money depending on how close they are to the center. Specifically, the cells on the edge will each have $1, the next row of cells inside them will each have $2, then $3, and the center cell will have $4. At game start, the board will look as follows: $ $1 $1 $1 $1 $1 $1 $1 $1 $2 $2 2 $2 $2 $2 $ 1 $1 $2 $3 $3 $3 $2 $1 $1 S2 $3 $4 $3 $2 $1 $1 S2 $3 $3 $3 $ 2 $1 $1 1 S2 $2 $2 $ $2 $2 $1 $1 1 $1 $1 $1 $1 $ 1 $1 In Part E the display of the game board will be revised to look as follows: 0 1 2 3 4 5 6 --+ | LA $1 $1 $1 $1 $1 $1 $1 1 | $ 1 $2 $2 $ 2 $2 $ 2 $1 | B 1 $1 $2 $ 3 $3 $3 $2 $ 1 ic $1 $2 $4 $3 $2 $1 1 E 1 $1 $2 $3 $3 $3 $2 $1 | E F $1 $2 $2 $2 $2 $ 2 $1 | $1 $1 $1 $1 $1 $1 $1 0 1 2 3 4 5 6 The Dice The simulated dice have four sides with the values 0, 1, 2, and 3. When choosing a grid cell in the game, two dice are rolled and their values are added to give the row number. For example, if 1 and 3 were rolled, the row would be 1 + 3 = 4. Another two dice are rolled and added to choose the column. As a result, the cells near the center will be chosen more frequently. The program will use symbols to print the dice values so that they look like they are on dice. For example: Row Column +---+ +---+ +---+ +---+ | 2 | 3 | | 1 | | 0 +---+ +---+ +--- Here, row 2 + 3 = 5 and column 1 + 0 = 1 were rolled, so the cell chosen is Fi. Requirements Part A: The Board Size [20% test program] In Part A, you will create constants and functions related to the board size. Put the constants and function prototypes in a file named BoardSize.h and the function implementations in a file named BoardSize.cpp. Throughout this course, make sure that you use exactly the specified file names, which are case sensitive. Here, B and S are uppercase and the remaining letters are lowercase. By the end of Part A, you will have functions with the following prototypes: char getRowName (int row); char getColumnName (int column); Perform the following steps: 1. As the first line in BoardSize.h and every other header (.h) file for the rest of the course, put the following line: #pragma once This line tells the C++ compiler to only compile this file once even if it happens to be #included multiple times: 2. In BoardSize.h, define BOARD_SIZE and BOARD_CELL_COUNT as integer constants. BOARD_SIZE should have a value of 7 and BOARD_CELL_COUNT should have a value of BOARD_SIZE + BOARD_SIZE. 3. In BoardSize.h, copy in the function prototypes shown above. You are now finished BoardSize.h. 4. Near the top of BoardSize.cpp, add the following command: #include "BoardSize.h" 5. Add an implementation for the getRoviName function that returns the name character for that row. For example, if O is passed in as the row parameter, then the name character is 'A', so 'A' should be returned. Hint: You can use mathematical operators, such as addition and subtraction, on chars. The uppercase letters form a sequence, so you can add 'A' + 2 and get 'C'. The same kinds of operations apply to lowercase letters and to digits. 6. Add an implementation for the getColumnName function that returns the character name of that column. Hint: Column names are chars starting with '0', and 'O' + 3 == '3'. Test your BoardSize module using the TestBoardSize1.cpp program provided. You will also need the TestHelper.h and TestHelper.cpp files. Note: All the test programs for the game will use the same TestHelper.h and TestHelper.cpp files. Note: For additional information on compiling programs consisting of multiple files, please consult link. Part B: The Game Board (25% = 20% test program + 2% output + 3% code] In Part B, you will create functions related to the board itself. the function prototypes in a file named Board.h and the function implementations in a file named Board.cpp. By the end of Part B, you will have functions with the following prototypes: void boardInit (Board board); int boardGetAt (const Board board, int row, int column); void boardSetAt (Board board, int row, int column, int value); void boardprint (const Board board); In Part E, you will add helper functions with the following prototypes: void boardPrintColumnNameRow (); void boardPrintBorderRow (); void boardPrintEmptyRow(); void boardPrintDataRow (const Board board, int row); Perform the following steps: 1. In Board.cpp, use #include to include the library, "BoardSize.h", and "Board.h". Remember to put using namespace std;. 2. In Board.h, use typedef to define a Board type corresponding to a 2D array of ints with dimensions BCARD_SIZE and BOARD_SIZE. The typedef uses the BOARD_SIZE constant, so Board.h should #include "BoardSize.h". 3. In Board.h, copy in the function prototypes shown above. 4. In Board.cpp, add an implementation for the boardinit function that sets all the elements of the array. The values should depend on the array position, as described in The Game Board above. You must use at least two loops in the implementation, . Hint: Use a pair of nested for loops for the initialization. . Hint: Start by initializing all the elements of the board to the same value, such as 1. Then, after that works, change your function to set them to the correct values. Hint: The abs function from the library returns the absolute value of a variable. So abs (v - MIDDLE) will return how far v is from MIDDLE. It will help you to figure out how far you are from the middle of the array. 5. Add an implementation for the boardGetAt function that returns the amount of money at the specified position. The function must determine the value from the array. 6. Add an implementation for the boardsetAt function that sets the amount of money at the specified array position to the specified value. 7. Add an implementation for the boardprint function that prints the array contents in the first (simpler) format shown under The Game Board above. The four functions named boardPrint + listed above will be used in Part E to print the board in the second format. Note: The + in boardPrint* is a common computer science convention for "anything". So boardPrint* means boardprintColumnNameRow, boardPrintBorderRow, boardPrintEmptyRow, and boardPrintDataRow. You can use the same syntax on Hercules (or any similar system) when entering commands. For example, g++ -c *.cpp will compile all the files in the current directory that have a .cpp extension. 8. Test your Board module using the TestBoardl.cpp program provided. Again, you will need TestHelper.h and TestHelper.opp. Part C: Simulated Dice (10% = 7% test program + 3% output] In Part C, you will add constants and functions related to rolling dice. Put the constants and functions in Dice.h and the function implementations in Dice.cpp. By the end of Part C, you will have functions with the following prototypes: void diceInit(); int diceRoll (); void dicePrint2and2 (int ri, int r2, int cl, int c2); Perform the following steps: 1. In Dice.cpp, include the , , and libraries and "Dice.h". The library (the standard library) contains functions for generating random numbers, and the library will be needed for initialization. Remember to put using namespace std; 2. In Dice.h, define DICE_SIDE_COUNT as an integer constant with value 4. Note: You will not need any #includes in Dice.h. However, you should still put #pragma once. 3. In Dice.h, copy in the function prototypes shown above. 4 In Dice.cpp, add an implementation for the diceInit function. The only thing it should contain is the line: srand( (unsigned int)time (NULL)); Note: This line will seed the random number generator based on the current time. Without it, you would get the same "random" numbers each time you ran the program. You are not expected to understand how this line works. Debugging: If you have an intermittent bug, this line may be why it only sometimes happens. Try commenting it out. If the bug now always happens, you will find it much easier to fix. If it never happens, try calling srand with a number as an argument(e.g. srand(4) or srand (123456789), etc.) and see if the bug happens reliably then. If it still never happens, try a few other numbers. If the bug still happens unpredictably, randomness is not the problem. Check if you ever use an invalid array index. 5. Add an implementation for the dicekoll function that returns a random number in the half- open interval [0, DICE_SIDE_COUNT). Note: A half-open interval includes the lower bound but not the upper bound. So this function should sometimes return 0, but it should never return DICE_SIDE_COUNT. Hint: You can use the rand() function to get a random number. You can then use the modulus operator (a $ b) to get an integer from 0 to b - 1. 6. Add an implementation for the dicePrint2and2 function that prints a picture of four dice. Also print row and column labels, exactly as shown under The Dice above. The numbers shown on the dice should be the values passed in as the four parameters. Assume that the numbers will always have exactly one digit. 7. Test your Dice module using the TestDicel.cpp program provided. Once again, you will need TestHelper.h and TestHelper.cpp.cpp. 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 libraries in Main.cpp as well as for all of your header files. Reminder: Whenever you #include standard libraries such as , you will also need the line: using namespace std; . i Reminder: Put #pragma once at the top of every header (. h) file. Reminder: Do not put #pragma once in any source (.cpp) file. Reminder: Never #include any source (.cpp) 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 a 2D array of ints to be the game board and initialize it using another one of your functions. 3. Define a constant with the value 2 for the number of players. Declare a 10 array for the money that the players have and initialize its two elements 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 O and Player 1. 4. Add a main loop to your main function. This is a loop that will run continually until the program terminates. Each time through the loop, print "> " to prompt the user and then read a line of user input using getline. If the input is ever "q", 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 row and two for the column. You will need to call one of your functions four times and save the results in four variables. Print them 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 +---+ +---+ +--- |0|| 11 Rolled cell: Fl 9. 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: $4 + $2 = $6 Part E: Improved Game Board Display (10% output) In Part E, you will improve the display of the game board. By the end, it will look like the revised game board shown under The Game Board above. Perform the following steps: 1. Add an implementation for the boardPrintDataRow function. It should print the values for one row of the board in the same format as in Part B. Change your board Print function to call the board PrintDataRow function, 2. Add the border to the game board. Add an implementation for the boardPrintBorderRow function. You will also need to call it and update the board PrintDataRow function. Note: At this point, your game boarder will be smaller than the one in the example output. 3. Increase the spacing between the values on the game board. Add an implementation for the boardPrintEmptyRow function. You will need to update boardprint and two other functions. 4. Print the row and column labels on the four sides of the game board. Add an implementation for the boardprintColumnNameRow function and update the boardprintDatakow function. Call the getRowName and getColumnName functions. Update the appropriate other functions. Formatting ( -10% if not done] 1. Neatly indent your program using a consistent indentation scheme. 2. Put spaces around your arithmetic operators: x = x + 3; 3. Use symbolic constants, such as BOARD SIZE, when appropriate. 4. Include a comment at the top of Main.cpp that states your name and student number. 5. Format your program so that it is easily readable. Things that make a program hard to read include: Very many blank lines. If more than half your lines are blank, you probably have too many. The correct use of blank lies is to separate logically distinct sections of your program. Multiple commands on the same line. In general, don't do this. You can if it makes the program clearer than if the same commands were on separate lines. Uninformative variable names. For a local variable that is only used for a few lines, it doesn't really matter. But a variable that is used over a larger area (including all global and member variables) should have a name that documents its purpose. Similarly, parameters should have self-documenting names because the function will be called elsewhere in the program. Submission Submit a complete copy of your source code. You should have the following files with exactly these names: 1. BoardSize.h 2. BoardSize.cpp 3. Board.h 4. Board.cpp 5. Dice.h 6 Dice. CPP 7. Main.cpp Note: A Visual Studio .sln file does NOT contain the source code; it is just a text file. You do not need to submit it. Make sure you submit the .cpp files and .h files. Note: You do not need to submit the test programs. The marker has those already. If possible, convert all your files to a single archive (.zip file) before handing them in Do NOT submit a compiled version Do NOT submit intermediate files, such as: Debug folder Release folder ipch folder .ofiles *.ncb, *. sdf, or *.db files Do NOT submit a screenshot C The main purpose of this assignment is to give you practice using two-dimensional arrays, including passing two-dimensional arrays to functions. For Part A, you will add constants and functions relating to the size of the game board. For Part B, you will add functions to handle the game board itself. For Part C, you will add constants and functions related to simulated dice. For Part D, you will use the constants and functions from Parts A, B, and C to write the game program. Then, for Part E, you will improve the display of the game board. Another purpose of this assignment is to familiarize you with multi-file programs. To keep the assignment from getting to be too long, the files are small and the functions are mostly short. Many functions only contain a single line of code. Warning: The test programs used in this course sometimes capture and tests the output from the cout buffer. Therefore, you must use cout to print your output. If you print it in some other way, (e.g. using printf or cerr), the test program will not see it. Then you will get a mark of zero for that portion of the assignment The Game Board The game board will be represented as a 2-dimensional array. It is 7 x 7 cells in size. The elements of the array will store the amount of money in the different grid cells. The grid rows will be named using the (uppercase) letters 'A' to 'G', and the grid columns will be named using the digits 'O' to '6'. Thus, each cell will have a unique name such as A2 (row 0, column 2) or 26 (row 4, column 6). The cells on the board will start with more or less money depending on how close they are to the center. Specifically, the cells on the edge will each have $1, the next row of cells inside them will each have $2, then $3, and the center cell will have $4. At game start, the board will look as follows: $ $1 $1 $1 $1 $1 $1 $1 $1 $2 $2 2 $2 $2 $2 $ 1 $1 $2 $3 $3 $3 $2 $1 $1 S2 $3 $4 $3 $2 $1 $1 S2 $3 $3 $3 $ 2 $1 $1 1 S2 $2 $2 $ $2 $2 $1 $1 1 $1 $1 $1 $1 $ 1 $1 In Part E the display of the game board will be revised to look as follows: 0 1 2 3 4 5 6 --+ | LA $1 $1 $1 $1 $1 $1 $1 1 | $ 1 $2 $2 $ 2 $2 $ 2 $1 | B 1 $1 $2 $ 3 $3 $3 $2 $ 1 ic $1 $2 $4 $3 $2 $1 1 E 1 $1 $2 $3 $3 $3 $2 $1 | E F $1 $2 $2 $2 $2 $ 2 $1 | $1 $1 $1 $1 $1 $1 $1 0 1 2 3 4 5 6 The Dice The simulated dice have four sides with the values 0, 1, 2, and 3. When choosing a grid cell in the game, two dice are rolled and their values are added to give the row number. For example, if 1 and 3 were rolled, the row would be 1 + 3 = 4. Another two dice are rolled and added to choose the column. As a result, the cells near the center will be chosen more frequently. The program will use symbols to print the dice values so that they look like they are on dice. For example: Row Column +---+ +---+ +---+ +---+ | 2 | 3 | | 1 | | 0 +---+ +---+ +--- Here, row 2 + 3 = 5 and column 1 + 0 = 1 were rolled, so the cell chosen is Fi. Requirements Part A: The Board Size [20% test program] In Part A, you will create constants and functions related to the board size. Put the constants and function prototypes in a file named BoardSize.h and the function implementations in a file named BoardSize.cpp. Throughout this course, make sure that you use exactly the specified file names, which are case sensitive. Here, B and S are uppercase and the remaining letters are lowercase. By the end of Part A, you will have functions with the following prototypes: char getRowName (int row); char getColumnName (int column); Perform the following steps: 1. As the first line in BoardSize.h and every other header (.h) file for the rest of the course, put the following line: #pragma once This line tells the C++ compiler to only compile this file once even if it happens to be #included multiple times: 2. In BoardSize.h, define BOARD_SIZE and BOARD_CELL_COUNT as integer constants. BOARD_SIZE should have a value of 7 and BOARD_CELL_COUNT should have a value of BOARD_SIZE + BOARD_SIZE. 3. In BoardSize.h, copy in the function prototypes shown above. You are now finished BoardSize.h. 4. Near the top of BoardSize.cpp, add the following command: #include "BoardSize.h" 5. Add an implementation for the getRoviName function that returns the name character for that row. For example, if O is passed in as the row parameter, then the name character is 'A', so 'A' should be returned. Hint: You can use mathematical operators, such as addition and subtraction, on chars. The uppercase letters form a sequence, so you can add 'A' + 2 and get 'C'. The same kinds of operations apply to lowercase letters and to digits. 6. Add an implementation for the getColumnName function that returns the character name of that column. Hint: Column names are chars starting with '0', and 'O' + 3 == '3'. Test your BoardSize module using the TestBoardSize1.cpp program provided. You will also need the TestHelper.h and TestHelper.cpp files. Note: All the test programs for the game will use the same TestHelper.h and TestHelper.cpp files. Note: For additional information on compiling programs consisting of multiple files, please consult link. Part B: The Game Board (25% = 20% test program + 2% output + 3% code] In Part B, you will create functions related to the board itself. the function prototypes in a file named Board.h and the function implementations in a file named Board.cpp. By the end of Part B, you will have functions with the following prototypes: void boardInit (Board board); int boardGetAt (const Board board, int row, int column); void boardSetAt (Board board, int row, int column, int value); void boardprint (const Board board); In Part E, you will add helper functions with the following prototypes: void boardPrintColumnNameRow (); void boardPrintBorderRow (); void boardPrintEmptyRow(); void boardPrintDataRow (const Board board, int row); Perform the following steps: 1. In Board.cpp, use #include to include the library, "BoardSize.h", and "Board.h". Remember to put using namespace std;. 2. In Board.h, use typedef to define a Board type corresponding to a 2D array of ints with dimensions BCARD_SIZE and BOARD_SIZE. The typedef uses the BOARD_SIZE constant, so Board.h should #include "BoardSize.h". 3. In Board.h, copy in the function prototypes shown above. 4. In Board.cpp, add an implementation for the boardinit function that sets all the elements of the array. The values should depend on the array position, as described in The Game Board above. You must use at least two loops in the implementation, . Hint: Use a pair of nested for loops for the initialization. . Hint: Start by initializing all the elements of the board to the same value, such as 1. Then, after that works, change your function to set them to the correct values. Hint: The abs function from the library returns the absolute value of a variable. So abs (v - MIDDLE) will return how far v is from MIDDLE. It will help you to figure out how far you are from the middle of the array. 5. Add an implementation for the boardGetAt function that returns the amount of money at the specified position. The function must determine the value from the array. 6. Add an implementation for the boardsetAt function that sets the amount of money at the specified array position to the specified value. 7. Add an implementation for the boardprint function that prints the array contents in the first (simpler) format shown under The Game Board above. The four functions named boardPrint + listed above will be used in Part E to print the board in the second format. Note: The + in boardPrint* is a common computer science convention for "anything". So boardPrint* means boardprintColumnNameRow, boardPrintBorderRow, boardPrintEmptyRow, and boardPrintDataRow. You can use the same syntax on Hercules (or any similar system) when entering commands. For example, g++ -c *.cpp will compile all the files in the current directory that have a .cpp extension. 8. Test your Board module using the TestBoardl.cpp program provided. Again, you will need TestHelper.h and TestHelper.opp. Part C: Simulated Dice (10% = 7% test program + 3% output] In Part C, you will add constants and functions related to rolling dice. Put the constants and functions in Dice.h and the function implementations in Dice.cpp. By the end of Part C, you will have functions with the following prototypes: void diceInit(); int diceRoll (); void dicePrint2and2 (int ri, int r2, int cl, int c2); Perform the following steps: 1. In Dice.cpp, include the , , and libraries and "Dice.h". The library (the standard library) contains functions for generating random numbers, and the library will be needed for initialization. Remember to put using namespace std; 2. In Dice.h, define DICE_SIDE_COUNT as an integer constant with value 4. Note: You will not need any #includes in Dice.h. However, you should still put #pragma once. 3. In Dice.h, copy in the function prototypes shown above. 4 In Dice.cpp, add an implementation for the diceInit function. The only thing it should contain is the line: srand( (unsigned int)time (NULL)); Note: This line will seed the random number generator based on the current time. Without it, you would get the same "random" numbers each time you ran the program. You are not expected to understand how this line works. Debugging: If you have an intermittent bug, this line may be why it only sometimes happens. Try commenting it out. If the bug now always happens, you will find it much easier to fix. If it never happens, try calling srand with a number as an argument(e.g. srand(4) or srand (123456789), etc.) and see if the bug happens reliably then. If it still never happens, try a few other numbers. If the bug still happens unpredictably, randomness is not the problem. Check if you ever use an invalid array index. 5. Add an implementation for the dicekoll function that returns a random number in the half- open interval [0, DICE_SIDE_COUNT). Note: A half-open interval includes the lower bound but not the upper bound. So this function should sometimes return 0, but it should never return DICE_SIDE_COUNT. Hint: You can use the rand() function to get a random number. You can then use the modulus operator (a $ b) to get an integer from 0 to b - 1. 6. Add an implementation for the dicePrint2and2 function that prints a picture of four dice. Also print row and column labels, exactly as shown under The Dice above. The numbers shown on the dice should be the values passed in as the four parameters. Assume that the numbers will always have exactly one digit. 7. Test your Dice module using the TestDicel.cpp program provided. Once again, you will need TestHelper.h and TestHelper.cpp.cpp. 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 libraries in Main.cpp as well as for all of your header files. Reminder: Whenever you #include standard libraries such as , you will also need the line: using namespace std; . i Reminder: Put #pragma once at the top of every header (. h) file. Reminder: Do not put #pragma once in any source (.cpp) file. Reminder: Never #include any source (.cpp) 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 a 2D array of ints to be the game board and initialize it using another one of your functions. 3. Define a constant with the value 2 for the number of players. Declare a 10 array for the money that the players have and initialize its two elements 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 O and Player 1. 4. Add a main loop to your main function. This is a loop that will run continually until the program terminates. Each time through the loop, print "> " to prompt the user and then read a line of user input using getline. If the input is ever "q", 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 row and two for the column. You will need to call one of your functions four times and save the results in four variables. Print them 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 +---+ +---+ +--- |0|| 11 Rolled cell: Fl 9. 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: $4 + $2 = $6 Part E: Improved Game Board Display (10% output) In Part E, you will improve the display of the game board. By the end, it will look like the revised game board shown under The Game Board above. Perform the following steps: 1. Add an implementation for the boardPrintDataRow function. It should print the values for one row of the board in the same format as in Part B. Change your board Print function to call the board PrintDataRow function, 2. Add the border to the game board. Add an implementation for the boardPrintBorderRow function. You will also need to call it and update the board PrintDataRow function. Note: At this point, your game boarder will be smaller than the one in the example output. 3. Increase the spacing between the values on the game board. Add an implementation for the boardPrintEmptyRow function. You will need to update boardprint and two other functions. 4. Print the row and column labels on the four sides of the game board. Add an implementation for the boardprintColumnNameRow function and update the boardprintDatakow function. Call the getRowName and getColumnName functions. Update the appropriate other functions. Formatting ( -10% if not done] 1. Neatly indent your program using a consistent indentation scheme. 2. Put spaces around your arithmetic operators: x = x + 3; 3. Use symbolic constants, such as BOARD SIZE, when appropriate. 4. Include a comment at the top of Main.cpp that states your name and student number. 5. Format your program so that it is easily readable. Things that make a program hard to read include: Very many blank lines. If more than half your lines are blank, you probably have too many. The correct use of blank lies is to separate logically distinct sections of your program. Multiple commands on the same line. In general, don't do this. You can if it makes the program clearer than if the same commands were on separate lines. Uninformative variable names. For a local variable that is only used for a few lines, it doesn't really matter. But a variable that is used over a larger area (including all global and member variables) should have a name that documents its purpose. Similarly, parameters should have self-documenting names because the function will be called elsewhere in the program. Submission Submit a complete copy of your source code. You should have the following files with exactly these names: 1. BoardSize.h 2. BoardSize.cpp 3. Board.h 4. Board.cpp 5. Dice.h 6 Dice. CPP 7. Main.cpp Note: A Visual Studio .sln file does NOT contain the source code; it is just a text file. You do not need to submit it. Make sure you submit the .cpp files and .h files. Note: You do not need to submit the test programs. The marker has those already. If possible, convert all your files to a single archive (.zip file) before handing them in Do NOT submit a compiled version Do NOT submit intermediate files, such as: Debug folder Release folder ipch folder .ofiles *.ncb, *. sdf, or *.db files Do NOT submit a screenshot C

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

Recommended Textbook for

Mastering Real Time Analytics In Big Data A Comprehensive Guide For Everyone

Authors: Lennox Mark

1st Edition

B0CPTC9LY9, 979-8869045706

More Books

Students also viewed these Databases questions

Question

c. What were you expected to do when you grew up?

Answered: 1 week ago

Question

4. Describe how cultural values influence communication.

Answered: 1 week ago

Question

3. Identify and describe nine cultural value orientations.

Answered: 1 week ago