Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete four of the functions according to the instructions. initBoard0 GIVEN: void initBoard (char board) ICOLS]) This function should initialize the game board state. tictacroe-cpp

image text in transcribed

Complete four of the functions according to the instructions.

initBoard0 GIVEN: void initBoard (char board) ICOLS]) This function should initialize the game board state. tictacroe-cpp All elements of the board array should be initialized with the EMPTY named constant. Do not print anything here. using nanespace atd: showBoard0 conat int ROaS-3 cor.st int COLS -3 void showBoard (char board] [COLS] const char This function should display the game board with labeled rows and columns 14 const char PLAYER X- char PLATER O Print a row with just the column numbers. .Create a double-nested for loop. Function prototypeS o For each row void initBoardl char board [ ] [COLS! ); void showboard (cbar bosrd[] [COLS void nakeHove (char board[l Icts], char player) bool gancover (char boared [1 [Cots]) Print a space, then the row letter, then the appropriate array values for that row. End with a newline makeMove(0 void makeMove (char board ICOLs,char player) Main Progra nt nain This function should input the current player's choice, and mark it on the game board. The first parameter is the game board array, the second parameter is the player marker (either 'x' or 'o) char board [ROWS] [COLS char carrentPlayer -PLAYER X Use a while loop to keep prompting the user until valid input is entered initBoard (board) sbowloazd (board) . The player should enter a two-character location (letterumber), for example: b2. The input should be validated (keep prompting while not valid) while (!ganeover(board)) { row must be a, b, or c ocolumn must be 1, 2, or 3 o and, the chosen location must be empty currentPlayer : (currentPlayer PLAYER X) ? PLAYER * ; PLAYER X; Once a valid location has be chosen, update the board return EXIT SUCCESS gameOver(0 bool gameOver (char board [cOLS) This predicate will examine the current state of the game board and return true if the end of the game is detected, false otherwise. If the game has ended, print one of the following messages before retuming true: . Player X wins! Player 0 wins! . Tie

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

Object Oriented Databases Prentice Hall International Series In Computer Science

Authors: John G. Hughes

1st Edition

0136298745, 978-0136298748

More Books

Students also viewed these Databases questions

Question

1. Does your voice project confidence? Authority?

Answered: 1 week ago