In the C programming language write a program capable of pla
In the C++ programming language write a program capable of playing 3D Tic-Tac-Toe against the user. Your program should use OOP concepts in its design. Use Inheritance to create a derived class from Tic-Tac-Toe class. You can use ASCII art to generate and display the 3x3x3 playing board. The program should randomly decide who goes first computer or user. Your program should know and inform the user if an illegal move was made (cell already occupied). The program should also keep the score and announce if one of the players wins or if a draw is achieved. While it is desirable for your program to play a strong game, this is not an Artificial Intelligence course so if your program does not play at a world champion level you will not be penalized for it.
Solution
#include <iostream>
 #include <iomanip>
 using namespace std;
 
 //Global constants
 const int COLUMNS = 3; //Number of columns on the board
 const int ROWS = 3; //Number of rows on the board
 
 void displayBoard(int [][COLUMNS ], int);   
 void playerA (int);
 void playerB (int);
 
 int main ()
 {
 int space = 0 ;
 int space2 = 0 ;
 int B[ROWS][COLUMNS ] = {1, 2, 3, 4, 5, 6, 7, 8, 9 };
 cout << \"The playing board looks like:\ \";
 displayBoard(B, ROWS);
 playerA (space);
 displayBoard(B, ROWS);
 system(\"Break Tea Time\");
 return 0;
 }
 
 
 void displayBoard ( int array[][COLS], int rows, int space, int space2 )
 {
 for (int x = 0; x < rows; x++)
 {
 for (int y = 0; y < COLUMNS ; y++)
 {
 cout << array[x][y] << \" \";
 }
 cout << endl;
 }
 }
 
 void playerA (int space)
 {
   
 cout << \"Enter the Number \ \";
 cin >> space ;
 int B[ROWS][COLUMNS ] = {1, 2, 3, 4, 5, 6, 7, 8, 9 };
 if (space = 1) B[0][0] = \'x\' ;
 if (space = 2) B[0][1] = \'x\' ;
 if (space = 3) B[0][2] = \'x\' ;
 if (space = 4) B[1][0] = \'x\' ;
 if (space = 5) B[1][1] = \'x\' ;
 if (space = 6) B[1][2] = \'x\' ;
 if (space = 7) B[2][0] = \'x\' ;
 if (space = 8) B[2][1] = \'x\' ;
 else if (space =9) B[2][2] = \'x\' ;
   
   
 }
 
 void playerB (int space2)
 
 {
 cout << \"Enter the number from 1 to 9\ \";
 cin >> space2 ;
 int B[ROWS][COLUMNS ] = {1, 2, 3, 4, 5, 6, 7, 8, 9 };
 if (space2 = 1) B[0][0] = \'x\' ;
 if (space2 = 2) B[0][1] = \'x\' ;
 if (space2 = 3) B[0][2] = \'x\' ;
 if (space2 = 4) B[1][0] = \'x\' ;
 if (space2 = 5) B[1][1] = \'x\' ;
 if (space2 = 6) B[1][2] = \'x\' ;
 if (space2 = 7) B[2][0] = \'x\' ;
 if (space2 = 8) B[2][1] = \'x\' ;
 else if (space2 =9) B[2][2] = \'x\' ;
 }
 
 char winner (char winner)
 {
 int B[ROWS][COLUMNS ] = {1, 2, 3, 4, 5, 6, 7, 8, 9 };
 if (B[0][0] == B[0][1] && B[0][1] == B[0][2])
 winner = B[0][0];
 if (B[1][0] == B[1][1] && B[1][1] == B[1][2])
 winner = B[1][0];
 if (B[2][0] == B[2][1] && B[2][1] == B[2][2])
 winner = B[2][0];
 if (B[0][0] == B[1][0] && B[1][0] == B[2][0])
 winner = B[1][0];
 if (B[0][1] == B[1][1] && B[1][1] == B[2][1])
 winner = B[1][1];
 if (B[0][2] == B[1][2] && B[1][2] == B[2][2])
 winner = B[2][2];
 if (B[0][0] == B[1][1] && B[1][1] == B[2][2])
 winner = B[2][2];
 if (B[0][2] == B[1][1] && B[1][1] == B[2][0])
 winner = B[1][1];
 return winner ;
 }


