In: Computer Science
Make a Tic Tac Toe game for 2 players to play using 2D arrays
and classes. Do not add more #include functions other than the ones
listed (such as #include <stdio.h> etc).
Using the tictactoeGame class, write a main program that uses a
tictactoeGame to implement a game in which two players (you and a
friend) take turns placing X’s and O’s onto the board. After each
turn, the current board configuration should be displayed, and once
a player connects three of a kind, the game should end declaring
that player the winner.
class tictactoeGame
{
public:
char
boardConfig[3][3]; // two dimensional array stores
current board configuration
// Constructor:
// set boardConfig[i][j]
to be ' ' (the space character)
// for 0<= i <= 2,
0<= j <= 2
tictactoeGame()
{
//fill this
in
}
//put an 'X' character at the given
location
bool placeX(int x, int
y)
{
//fill this
in
}
//put an 'O' character at the given
location
bool placeO(int x, int
y)
{
//fill this
in
}
//set all positions to character ' '.
void clear()
{
//fill this
in
}
// Return true if
there are 3 'X' marks placed in a single
// column, row, or
diagnol. Return false otherwise.
bool xWins()
{
//fill this
in
}
// Return true if
there are 3 'O' marks placed in a single
// column, row, or
diagnol. Return false otherwise.
bool oWins()
{
//fill this
in
}
// Return true if
there are either 3 'X' marks or 3 'O' marks
// placed in a single
column, row, or diagnol, or if the board is full.
// Return false otherwise.
bool gameOver()
{
//fill this
in
}
// cout a nice
looking picture of the board configuration
void display()
{
//fill this
in
}
};
int main()
{
return 0;
}
|
Note: This is my version of tic tac toe game in java, just go through it and ask me if you have any doubts or queries related to the program
And please give a positive feedback if you like my answer
Happy Learning