Problem statement
Design the object model and core APIs for a Dots-and-Boxes engine: players take turns drawing edges between dots, claim completed boxes, and earn an extra turn whenever they close a box.
Operating context. A rectangular grid of (m+1) by (n+1) dots forms m by n boxes. Two or more players alternate; on a turn a player draws one undrawn edge between adjacent dots. Drawing the fourth side of a box claims it for that player, and a single edge can complete up to two boxes at once. Completing at least one box grants the same player another turn; otherwise play passes on. The game ends when every edge is drawn, and the player with the most claimed boxes wins. Single in-process match, one game at a time.
Out of scope. AI strategy and chain analysis, networked multiplayer, non-rectangular or irregular boards, replay/history persistence, and any rendering or animation.
What to produce. The class model (board, dot, edge, box, move, game, player, scoreboard), the public API each exposes, and how an edge maps to the up-to-two boxes it can complete. Be explicit about how box-completion is detected without scanning the whole board, how the extra-turn rule stays a single total transition, how N-player and 2-player games share one turn engine, and how scores are derived rather than set directly.
Requirements
This assessment is a Premium feature.
The statement above is free to read. The functional and non-functional requirements, and the graded canvas that scores your design against them, come with Premium.
Topics
- System Design LLD
- Oop Solid
- Patterns State
- Oop Encapsulation
- Domain Board-Games