Bird
0
0

How would you design the Request class to handle both floor number and direction in a scalable elevator system?

hard📝 Trade-off Q8 of 15
LLD - Design — Elevator System
How would you design the Request class to handle both floor number and direction in a scalable elevator system?
AInclude attributes for floor number and direction, with methods to validate direction
BOnly store floor number; direction is irrelevant
CStore direction as a boolean without floor number
DUse a global variable for direction instead of class attribute
Step-by-Step Solution
Solution:
  1. Step 1: Identify required data for Request

    Request must know floor and direction to serve user properly.
  2. Step 2: Design for scalability

    Attributes for floor and direction with validation methods ensure correctness and future extension.
  3. Final Answer:

    Include attributes for floor number and direction, with methods to validate direction -> Option A
  4. Quick Check:

    Request needs floor and direction attributes [OK]
Quick Trick: Store both floor and direction in Request for clarity [OK]
Common Mistakes:
MISTAKES
  • Ignoring direction
  • Using global variables
  • Storing incomplete data

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes