Bird
Raised Fist0

What is the primary reason to use a hierarchy of classes for board and pieces in a game design?

easy🧠 Conceptual Q1 of Q15
LLD - Design — Chess Game
What is the primary reason to use a hierarchy of classes for board and pieces in a game design?
ATo reuse common code and represent shared behaviors
BTo make the game run faster by avoiding classes
CTo store all pieces in a single flat list without categories
DTo prevent any piece from moving on the board
Step-by-Step Solution
Solution:
  1. Step 1: Understand class hierarchy purpose

    Class hierarchies help organize code by grouping shared behaviors and properties in a base class.
  2. Step 2: Apply to board game pieces

    Pieces share common features like position and movement rules, so a base class avoids repeating code.
  3. Final Answer:

    To reuse common code and represent shared behaviors -> Option A
  4. Quick Check:

    Class hierarchy purpose = Reuse code [OK]
Quick Trick: Base classes hold shared features for all pieces [OK]
Common Mistakes:
MISTAKES
  • Thinking hierarchy slows down the game
  • Ignoring code reuse benefits
  • Confusing storage structure with class design

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes