LLD - Design — Tic-Tac-Toe GameTo add a feature where players can undo their last move, which class should maintain a history of moves and why?AGame class, because it controls the overall game state and flowBPlayer class, because each player knows their own movesCBoard class, because it holds the current state of piecesDMove class, because it represents individual movesCheck Answer
Step-by-Step SolutionSolution:Step 1: Identify responsibility for game state historyUndo requires tracking moves and reverting state, best managed by Game class.Step 2: Analyze other classesPlayer knows moves but not full game state; Board holds current state but not history; Move is data object.Final Answer:Game class maintains move history for undo -> Option AQuick Check:Undo history = Game class responsibility [OK]Quick Trick: Game class manages undo by tracking moves [OK]Common Mistakes:MISTAKESStoring history in Player or BoardExpecting Move class to manage history
Master "Design — Tic-Tac-Toe Game" in LLD9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepArchTryChallengeDesignRecallScale
More LLD Quizzes Behavioral Design Patterns — Part 1 - Observer pattern - Quiz 11easy Behavioral Design Patterns — Part 1 - Template Method pattern - Quiz 13medium Behavioral Design Patterns — Part 1 - Observer pattern - Quiz 10hard Behavioral Design Patterns — Part 2 - Mediator pattern - Quiz 7medium Design — Parking Lot System - Concurrency considerations - Quiz 3easy Design — Parking Lot System - Class identification (ParkingLot, Floor, Spot, Vehicle) - Quiz 13medium Design — Parking Lot System - Enum usage (VehicleType, SpotType) - Quiz 4medium Design — Parking Lot System - Concurrency considerations - Quiz 14medium Design — Tic-Tac-Toe Game - Why game design tests model-view separation - Quiz 8hard Design — Tic-Tac-Toe Game - Why game design tests model-view separation - Quiz 1easy