``````// Daryl Sanderson & Ladarius White
//Tic Tat Toe
//Professor Cook
//Programming II
// 11 am
#include <iostream>
using namespace std;

int main ()
{
char square1 (' ');
char square2 (' ');
char square3 (' ');
char square4 (' ');
char square5 (' ');
char square6 (' ');
char square7 (' ');
char square8 (' ');
char square9 (' ');
int playerTurn = 1;
bool GameComplete = true;

// game
do
{
// This will print the typical grid for the tic tat toe game.
cout << " Welcome to the wonderful world of Tic Tat Toe " << endl;
cout << " WE HOPE YOU ENJOY!!! " << endl;
cout << "----------- " << endl;
cout << square1 << " | " << square2 << " | " << square3 << " | " << endl;
cout << "----------- " << endl;
cout << square4 << " | " << square5 << " | " << square6 << " | " << endl;
cout << "----------- " << endl;
cout << square7 << " | " << square8 << " | " << square9 << " | " << endl;
cout << "----------- " << endl;
cout << " The boxes are numbered left to right starting with 1. " << endl;

//The following code demonstrates that player one will be displayed as "Xs" and player two as "Cs".
char player;
if (playerTurn == 1)
{
player = 'X';
}
else
{
player = 'C';
}

//Next we tell the players to make their move.

cout << "Player" << playerTurn << " it is your turn!! Make a move please, selecting a box between 1-9: " << endl;
bool trueMove;

// this loop will continue to run until a valid move is entered.
do
{
char move;
cin >> move;
trueMove = true;

// Check for Valid moves.
if (move == '1' && square1 == ' ')
{
square1 = player;
}
else if ( move == '2' && square2 == ' ')
{
square2 = player;
}
else if ( move == '3' && square3 == ' ')
{
square3 = player;
}
else if ( move == '4' && square4 == ' ')
{
square4 = player;
}
else if ( move == '5' && square5 == ' ')
{
square5 = player;
}
else if ( move == '6' && square6 == ' ')
{
square6 = player;
}
else if ( move == '7' && square7 == ' ')
{
square7 = player;
}
else if ( move == '8' && square8 == ' ')
{
square8 = player;
}
else if ( move == '9' && square9 == ' ')
{
square9 = player;
}
else
{
cout << " This is not a valid move! Please enter a number between 1-9. Thank you " << endl;
trueMove = false;
}
}
while (!trueMove);

GameComplete = false;
bool GameWin = true;
//This loop checks to see if the player is a winner.
if (square1 != '1')
{
if (square2 == player && square1 == player && square3 == player && square1 == player)
{
GameComplete = true;
}

if (square4 == player && square1 == player && square7 == player && square1 == player)
{
GameComplete = true;
}
}

if (square5 != '5')
{
if (square1 == player && square5 == player && square9 == player && square5 == player)
{
GameComplete = true;
}
if (square2 == player && square5 == player && square8 == player && square5 == player)
{
GameComplete = true;
}
if (square3 == player && square5 == player && square7 == player && square5 == player)
{
GameComplete = true;
}
if (square4 == player && square5 == player && square6 == player && square5 == player)
{
GameComplete = true;
}
}
if (square9 != '9')
{
if (square3 == player && square9 == player && square6 == player && square9 == player)
{
GameComplete = true;
}
if (square7 == player && square9 == player && square8 == player && square9 == player)
{
GameComplete = true;
}
}

//This if statement checks to see if the game has reached a draw
if ( square1 != '1' && square2 != '2' && square3 != '3'
&& square4 != '4' && square5 != '5' && square6 != '6'
&& square7 != '7' && square8 != '8' && square9 != '9' && !GameComplete)
{
GameComplete = true;
GameWin = false;
}

if (GameComplete)
{
if (GameWin)
{
cout << "Player" << playerTurn << " wins!!!!!" << endl;
}

// Print the Winning Board.
cout << "----------- " << endl;
cout << square1 << " | " << square2 << " | " << square3 << " | " << endl;
cout << "----------- " << endl;
cout << square4 << " | " << square5 << " | " << square6 << " | " << endl;
cout << "----------- " << endl;
cout << square7 << " | " << square8 << " | " << square9 << " | " << endl;
cout << "----------- " << endl;

cout << "Game Over!! Play Again? Y/N? " << endl;
char replay;
cin >> replay;

if (replay == 'Y' || replay == 'y')
{
GameComplete = false;
//this loop clears the board and redies it for the next opponents
square1 = ' ';
square2 = ' ';
square3 = ' ';
square4 = ' ';
square5 = ' ';
square6 = ' ';
square7 = ' ';
square8 = ' ';
square9 = ' ';
}
playerTurn = 1;
}

else
{
//switch players
if (playerTurn == 1)
{
playerTurn = 2;
}
else
{
playerTurn = 1;
}
}
} while (!GameComplete);
}
``````