(Tic-Tac-Toe) Create class TicTacToe that will enable you to write a complete app to play the game of Tic-Tac-Toe. The class contains a private 3-by-3 rectangular array of integers. The constructor should initialize the empty board to all 0s. Allow two human players. Wherever the first player moves, place a 1 in the specified square, and place a 2 wherever the second player moves. Each move must be to an empty square. After each move, determine whether the game has been won and whether it’s a draw.
I want this in C#
There are 2 files required for this game to run. 1st file is TicTacToe.cs and 2nd is the driver file. Both the file codes are posted below in their respective tables. You are required to create a Windows Console C# Project in visual studio and then create 2 class files named TicTacToe.cs and another as Program.cs and then copy the below codes and paste into these files one by one.
| TicTacToe.cs |
|
using System; namespace Tic_Tac_Toe public TicTacToe() public bool isFirstPlayerTurn() public void printInstructions() public void printBoard() Console.WriteLine(" " + board[0, 0] + " | " + board[0, 1] + " | " + board[0, 2]);
Console.WriteLine("_____|_____|_____");
Console.WriteLine(" | |");
Console.WriteLine(" " + board[1, 0] + " | " + board[1, 1] + " | " + board[1, 2]);
Console.WriteLine("_____|_____|_____");
Console.WriteLine(" | |");
Console.WriteLine(" " + board[2, 0] + " | " + board[2, 1] + " | " + board[2, 2]);
} public bool selectCell(int row, int col) } } private bool isValidMove(int row, int col) public int checkWinner() else if((board[1, 0] == board[1, 1]) && (board[1, 0] ==
board[1, 2]) && (board[1, 0] != 0)) else if ((board[2, 0] == board[2, 1]) && (board[2, 0] ==
board[2, 2]) && (board[2, 0] != 0)) else if ((board[0, 0] == board[1, 0]) && (board[0, 0] ==
board[2, 0]) && (board[0, 0] != 0)) else if ((board[0, 1] == board[1, 1]) && (board[0, 1] ==
board[2, 1]) && (board[0, 1] != 0)) else if ((board[0, 2] == board[1, 2]) && (board[0, 2] ==
board[2, 2]) && (board[0, 2] != 0)) else if ((board[0, 0] == board[1, 1]) && (board[0, 0] ==
board[2, 2]) && (board[0, 0] != 0)) else if ((board[2, 2] == board[1, 1]) && (board[2, 2] ==
board[2, 0]) && (board[2, 2] != 0)) } |
| Program.cs |
|
using System; namespace Tic_Tac_Toe if(game.isFirstPlayerTurn()) Console.WriteLine(); bool validMove = game.selectCell(row, col); if (winner == 1) } Console.ReadKey(); |
OUTPUT



NOTE: If there is some issue with slash n and slash t (escape sequences) i.e., any output format related issues then please comment in the comment box and I will post the code screenshots.
(Tic-Tac-Toe) Create class TicTacToe that will enable you to write a complete app to play the...
Writing a code in C# console app Create class TicTacToe that will enable you to write a complete app to play the game of Tic-Tac-Toe. The class contains a private 3-by-3 rectangular array of integers. The constructor should initialize the empty board to all 0s. Allow two human players. Wherever the first player moves, place a 1 in the specified square, and place a 2 wherever the second player moves. Each move must be to an empty square. After each...
(Tic-Tac-Toe) Create a class Tic-Tac-Toe that will enable you to write a program to play Tic-Tac-Toe. The class contains a private 3-by-3 two-dimensional array. Use an enumeration to represent the value in each cell of the array. The enumeration’s constants should be named X, O and EMPTY (for a position that does not contain an X or an O). The constructor should initialize the board elements to EMPTY. Allow two human players. Wherever the first player moves, place an X...
Please make this into one class. JAVA Please: Tic Tac Toe class - Write a fifth game program that can play Tic Tac Toe. This game displays the lines of the Tic Tac Toe game and prompts the player to choose a move. The move is recorded on the screen and the computer picks his move from those that are left. The player then picks his next move. The program should allow only legal moves. The program should indicate when...
In Java create a program where a user plays Tic Tac Toe against the computer. Create a class TicTacToe that will enable you write a program to play Tic-Tac-Toe. The class contains a private 3x3 two-dimensional array. Use an enum type to represent the value in each cell of the array. The enum’s constants should be named X, O, and EMPTY (for a position that does not contain an X or O). The constructor should initialize the board elements to...
In a game of Tic Tac Toe, two players take turns making an available cell in a 3 x 3 grid with their respective tokens (either X or O). When one player has placed three tokens in a horizontal, vertical, or diagonal row on the grid, the game is over and that player has won. A stalemate occurs when all the cells on the grid have been filled with tokens and neither player has achieved a win. Write a program...
In a game of Tic Tac Toe, two players take turns making an available cell in a 3 x 3 grid with their respective tokens (either X or O). When one player has placed three tokens in a horizontal, vertical, or diagonal row on the grid, the game is over and that player has won. A stalemate occurs when all the cells on the grid have been filled with tokens and neither player has achieved a win. Write a program...
(Game: play a tic-tac-toe game) In a game of tic-tac-toe, two players take turns marking an available cell in a grid with their respective tokens (either X or O). When one player has placed three tokens in a horizontal, vertical, or diagonal row on the grid, the game is over and that player has won. A draw (no winner) occurs when all the cells in the grid have been filled with tokens and neither player has achieved a win. Create...
PYTHON Exercise 2. Tic-Tac-Toe In this exercise we are going to create a Tic-Tac-Toe game. 1. Create the data structure – Nine slots that can each contain an X, an O, or a blank. – To represent the board with a dictionary, you can assign each slot a string-value key. – String values in the key-value pair to represent what’s in each slot on the board: ■ 'X' ■ 'O' ■ ‘ ‘ 2. Create a function to print the...
Objective: To write a program to allow a game of Tic Tac Toe to be played, and to determine when the game is over Complete the TicTacToe program below. It will allow for a full game of Tic Tac Toe between two players, and it will tell you who won or if the game is over with no winner. Details: The TicTacToe board is stored in a 3x3 multidimensional list of characters containing spaces at the start of the game...
Write a c program that will allow two users to play a tic-tac-toe game. You should write the program such that two people can play the game without any special instructions. (assue they know how to play the game). Prompt first player(X) to enter their first move. .Then draw the gameboard showing the move. .Prompt the second player(O) to enter their first move. . Then draw the gameboard showing both moves. And so on...through 9 moves. You will need to:...