Bird
0
0

You want to design a system where each parking spot can only hold one vehicle at a time. Which class relationship best models this?

hard📝 Trade-off Q8 of 15
LLD - Design — Parking Lot System
You want to design a system where each parking spot can only hold one vehicle at a time. Which class relationship best models this?
AVehicle contains a list of Spots
BSpot has a reference to one Vehicle
CFloor inherits from Spot
DParkingLot contains multiple Vehicles directly
Step-by-Step Solution
Solution:
  1. Step 1: Understand one-to-one relationship

    Each spot holds exactly one vehicle at a time.
  2. Step 2: Model relationship

    Spot should have a reference to one Vehicle to represent occupancy.
  3. Final Answer:

    Spot has a reference to one Vehicle -> Option B
  4. Quick Check:

    One spot holds one vehicle = A [OK]
Quick Trick: Spot points to one vehicle to show occupancy [OK]
Common Mistakes:
MISTAKES
  • Assigning multiple spots to one vehicle
  • Using inheritance incorrectly
  • ParkingLot holding vehicles directly without spots

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes