Question: Write a C++ Program that matches the following output. In the array, gameBoard [O] [0] represents the top-left corner cell of the game grid. Similarly,

Write a C++ Program that matches the following output.Write a C++ Program that matches the following output. In the array,gameBoard [O] [0] represents the top-left corner cell of the game grid.Similarly, gameBoard [2] [2] represents the bottom-right corner cell of the board.Your main task in implementing the logic of the game is to

In the array, gameBoard [O] [0] represents the top-left corner cell of the game grid. Similarly, gameBoard [2] [2] represents the bottom-right corner cell of the board. Your main task in implementing the logic of the game is to write a function: void playMove( int board [3] [3], int row, int col bool& turn, bool& validMove, bool gameOver, int& winCode, // The board 2-d array // Board row where mouse is clicked // Board column where mouse is clicked // Whose turn is it? // Is the move valid? // Is the game over? // A code of winning sequence This function is to be implemented in the file playMove.cpp and it is called every time a player makes a move. It's goal to "play" the move and update the array representing the grid, among other variables. The playMove function takes the following parameters: board is the two-dimensional array representing the game board. Thea array is both input to and output of the function. . row and col indicate the board row and column where the mouse is clicked. They are only inputs to the function (hence, they are passed by value) validMove is a Boolean output of the function and it should be set to true if the move i:s valid i.e., the grid cell at row and col is empty) and to false otherwise. Note that since the variable is an output of the function, it is passed by reference If the move is valid, the function should update the board array at the appropriate location. turn is a Boolean variable that indicates whose turn it is, X (true) or O (false) upon entry to the function. If the move is valid, then the value of turn should change from true to false or from false to true to reflect the change in turn . The gameOver is a Boolean output of the function that should be set to true if the game is over as a result of this move (win or draw) and to false otherwise

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!