Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Part B: The Game Board (25% = 20% test program + 2% output + 3% code] In Part B, you will create functions related

image text in transcribedC++

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. Put 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 chars with dimensions BOARD_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

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

Beginning VB.NET Databases

Authors: Thearon Willis

1st Edition

1594864217, 978-1594864216

More Books

Students also viewed these Databases questions

Question

LO1 Explain how the workforce is changing in unpredicted ways.

Answered: 1 week ago

Question

LO6 List the components of job descriptions.

Answered: 1 week ago