Bird
0
0

In a board game design, which class should contain the logic for valid moves of a piece?

easy📝 Conceptual Q2 of 15
LLD - Design — Chess Game
In a board game design, which class should contain the logic for valid moves of a piece?
AThe base Piece class only
BA separate unrelated utility class
CThe Board class only
DEach specific piece subclass
Step-by-Step Solution
Solution:
  1. Step 1: Identify responsibility of move logic

    Each piece type has unique movement rules, so logic must be specific to piece subclasses.
  2. Step 2: Why not base or board class?

    The base class is generic; the board manages positions but not piece-specific moves.
  3. Final Answer:

    Each specific piece subclass -> Option D
  4. Quick Check:

    Move logic location = Piece subclass [OK]
Quick Trick: Specific moves belong to each piece type class [OK]
Common Mistakes:
  • Putting all move logic in base class
  • Assigning move logic to board class
  • Using unrelated utility classes for moves

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes