Coding Phone Mobile Engineer Reported Jun, 2025 Medium Frequency
Create a one-screen Tic-Tac-Toe game that two players can play locally. Use the standard 3-by-3 board: X takes the first turn, players alternate placing their marks in empty cells, and a player wins by completing a row, column, or diagonal. If all nine cells are occupied without a winner, the game ends in a draw.
Implement the game through the following component interface:
TicTacToe()
The screen should show the current board, indicate whose turn it is while play continues, and announce the winner or draw when the game finishes. Include a way to reset the board and begin a new match. Several small follow-up requirements may be discussed after the initial implementation.
Input: Start a new game and place X in the top-left cell, then O in the center cell.
Output: The board shows those two marks, and the next-turn indicator displays X.
Explanation: Players alternate turns, with X moving first.
Input: Play the moves X: top-left, O: center, X: top-middle, O: bottom-right, X: top-right.
Output: The game announces X as the winner.
Explanation: X occupies all three cells in the top row.
Input: Fill the board with X at top-left, top-right, center, bottom-left, and bottom-right; place O in the top-middle, middle-left, middle-right, and bottom-middle.
Output: The game reports a draw.
Explanation: Every cell is occupied, but neither mark forms a complete row, column, or diagonal.
X and O.X always starts, and turns alternate until the game ends.X the next player.