Bird
Raised Fist0

Which of the following enum definitions correctly models basic game states in a low-level design?

easy🧠 Conceptual Q3 of Q15
LLD - Design — Chess Game
Which of the following enum definitions correctly models basic game states in a low-level design?
Aenum GameState { MENU, PLAYING, PAUSED, GAME_OVER }
Benum GameState { 0: MENU, 1: PLAYING, 2: PAUSED, 3: GAME_OVER }
Cenum GameState = { 'MENU', 'PLAYING', 'PAUSED', 'GAME_OVER' }
Denum GameState { 'MENU' = 0, 'PLAYING' = 1, 'PAUSED' = 2, 'GAME_OVER' = 3 }
Step-by-Step Solution
Solution:
  1. Step 1: Understand enum syntax

    In most low-level languages like C or C++, enums are declared as enum Name { VALUE1, VALUE2, ... }.
  2. Step 2: Analyze options

    enum GameState { MENU, PLAYING, PAUSED, GAME_OVER } uses correct syntax. enum GameState { 0: MENU, 1: PLAYING, 2: PAUSED, 3: GAME_OVER } uses invalid key-value syntax. enum GameState = { 'MENU', 'PLAYING', 'PAUSED', 'GAME_OVER' } uses assignment with '=', which is incorrect. enum GameState { 'MENU' = 0, 'PLAYING' = 1, 'PAUSED' = 2, 'GAME_OVER' = 3 } uses string keys with assignment, which is invalid in low-level languages.
  3. Final Answer:

    enum GameState { MENU, PLAYING, PAUSED, GAME_OVER } -> Option A
  4. Quick Check:

    Standard enum syntax uses braces and comma-separated identifiers [OK]
Quick Trick: Low-level enums use braces and identifiers without quotes [OK]
Common Mistakes:
MISTAKES
  • Using key-value pairs inside enums in low-level languages
  • Assigning string values to enum members
  • Using '=' instead of braces for enum declaration

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes