Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(Tic-Tac-Toe) Write a program that allows two players to play the tic-tac-toe ga

ID: 3628184 • Letter: #

Question

(Tic-Tac-Toe) Write a program that allows two players to play the tic-tac-toe game. Your program must contain the class ticTacToe to implement a ticTacToe object. Include a 3-by-3 two-dimensional array, as a private member variable, to create the board. If needed, include additional member variables. Some of the operations on a ticTacToe object are printing the current board, getting a move, checking if a move is valid, and determining the winner after each move. Add additional operations as needed.

Explanation / Answer

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 #include #include using namespace std; class TicTacToe{ public: void print(); void play(); char determine(); TicTacToe(); private: int p1x,p1y; int p2x,p2y; char TicTacToeBoard[3][3]; }; TicTacToe::TicTacToe(){ char TicTacToeBoard[3][3] = {{'!','!','!'},{'!','!','!'},{'!','!','!'} }; // fill board TicTacToeBoard[p1x][p1y] = 'X'; // put x where p1 has coordinates TicTacToeBoard[p2x][p2y] = 'O'; // put y where p1 has coordinates } int main(){ TicTacToe playgame,winner; //create objects of type TicTacToe playgame.play(); // play game winner.determine(); // determine winner system("pause"); return 0; } void TicTacToe::print(){ // for printing board int row; int col; cout