Design a Tic Tac Toe Game

Easy
GamesStrategyObserver

Problem Statement

Design a Tic Tac Toe game system that supports:

  • Two human players (or one human vs. AI)
  • N×N board (default 3×3, extendable)
  • Win detection (row, column, diagonal)
  • Draw detection
  • Game reset

Design Requirements

Key Entities:

  • Game — Controls game flow
  • Board — N×N grid
  • Player — Human or AI player
  • Move — A position (row, col)
  • GameStatus — InProgress, Win, Draw

Key Behaviors:

  • makeMove(player, row, col) → applies move, returns GameStatus
  • isWinner(player) → checks if player has won
  • isDraw() → board is full without winner
  • reset() → clears board for new game

!Constraints

- Board size N is 3–10 - Win requires N in a row (same as board size) - A cell can only be claimed once - Players alternate turns — enforce turn order - Support both 2-player and player vs AI modes
Output

Run your code to see output here.