Design a Connect-Four-like board game
Company: Airbnb
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: hard
Interview Round: Onsite
Design an object-oriented model for a turn-based, grid-based “drop token” board game similar to Connect Four.
Game rules (define these precisely in your design):
- The board has `rows` and `cols`.
- Players alternate turns.
- A move chooses a column; the token falls to the lowest available row in that column.
- If a column is full, the move is invalid.
- A player wins by forming `K` consecutive tokens in a line (horizontal, vertical, or diagonal).
- The game ends when someone wins or the board is full (draw).
Requirements:
- Provide class/interface design (e.g., `Game`, `Board`, `Player`, `Move`, `Rules/WinCondition`).
- Show key methods and responsibilities (no need for full code, but be concrete).
- Make it easy to extend (e.g., different win conditions, different gravity direction, or different board sizes).
- Discuss how you would test the win-checking logic and move validation.
Quick Answer: This question evaluates object-oriented design, modularity, extensibility, and testability in modeling a turn-based, grid-based drop-token game, and is categorized under Software Engineering Fundamentals; it requires both conceptual architecture and practical application thinking.