Question: NEEDED IN C# Write a program to play Tic-Tac-Toe. The game is designed for two human players (Player 1 and Player 2). When the game
NEEDED IN C#
Write a program to play Tic-Tac-Toe. The game is designed for two human players (Player 1 and Player 2). When the game begins, initialize the empty 3 by 3 game board to all 0s. These 0s indicate that none of the 9 squares is taken. The two players take turns to pick squares. Wherever Player 1 picks, place a 1 in the specified square. Similarly, place a 2 wherever the second player picks. A player must pick a square that is empty. If the player picks a square that is already taken, the program should ask the player to pick another square. The player picks a square by entering the row number (1, 2 or 3) and the column number (1, 2 or 3) of the square he wants. You can assume that the user always enters valid row number and column number so you do not have to write code to handle row or column number less than 1 or greater than 3. Every time a square is picked, the computer should determine whether the game has been won and announce the winner if necessary. A player wins if he occupies all three squares in a row, a column, or a diagonal. If there is no winner after the whole game board is full, announce that the game is a draw.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
