Bird
0
0

Consider a system where the state changes based on commands:

medium📝 Analysis Q5 of 15
LLD - Design — Elevator System
Consider a system where the state changes based on commands:
if current_state == moving_up and command == moveDown: current_state = moving_down
What will be the state after starting at moving_up and receiving moveDown command?
Amoving_down
Bmoving_up
Cidle
Derror
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the condition

    If current state is moving_up and command is moveDown, state changes to moving_down.
  2. Step 2: Apply given inputs

    Starting at moving_up and receiving moveDown triggers the condition, so state becomes moving_down.
  3. Final Answer:

    moving_down -> Option A
  4. Quick Check:

    Command changes moving_up to moving_down [OK]
Quick Trick: Command moveDown switches moving_up to moving_down [OK]
Common Mistakes:
MISTAKES
  • Ignoring command effect
  • Assuming state stays same
  • Confusing moveDown with stop

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes