Design Tic-Tac-Toe

Tic Tac Toe is a two-player turn-based strategy game also known as Noughts and Crosses or Xs and Os. The game is played on a 3x3 grid, and each player takes turns marking a square with their symbol, either X or O. The goal of the game is to get three of your symbols in a row, either horizontally, vertically, or diagonally. The first player to achieve this wins the game. If all of the squares are filled and no player has won, the game ends in a draw.

https://firebasestorage.googleapis.com/v0/b/techprimer-fbfe6.appspot.com/o/lld%2Ftic-tac-toe.png?alt=media&token=15b3fad7-492e-44af-be82-e01ee219d966

Design a Tic Tac Toe game with the following requirements:

  1. The game should be played between two players using X and O.
  2. The game board should be a 3x3 matrix.
  3. Players take turns to place their respective symbol (X or O) on the game board.
  4. The first player to get three of their symbols in a row (horizontally, vertically, or diagonally) wins the game.
  5. The game should end when a player wins or all the squares on the game board have been filled with X and O (in which case the game is a draw).

Sample Input/Output: