Question: C++ For this exercise, you will create a Tic-Tac-Toe game for two players. An optional enhancement would be to create a computer opponent. While this

C++

For this exercise, you will create a Tic-Tac-Toe game for two players. An optional enhancement would be to create a computer opponent. While this program is an introduction to arrays, it will also be a quick review of functions and input validation. Program Specification For this lab you will need to implement a one-dimensional array, so the TTT board must be a single array of 9 characters. For this, as in all assignments, you are expected to follow the course programming style guidelines and to properly implement both header and source files for your functions.

The minimum functions you are required to implement are:

displayInstructions

o no input parameters

o displays the instructions

o does not return anything

showBoard

o pass in board safely (So that it cannot be changed)

o display current state

o does not return anything

getMove

o pass in the board

o get a move (must validate move is in range and square is unoccupied)

o does not have an explicit return, the board is updated via reference

checkWin

o pass in board safely o return true if win

checkDraw

o pass in board safely

o return true if draw

Play Again

o Ask if player wants to play again

o Validate user input (y/n, upper/lower)

o Return true if the player wants to play again

Main will define the game board array, call these functions, and loop until the game is over. It will then report which player won and ask if they want to play another game and repeat if yes. Your code will need to be flexible enough to handle alternating between players. Do not write duplicate code for each player.

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!