Bird
Raised Fist0

Which of the following is the correct way to represent a parking spot in a class diagram?

easy🧠 Conceptual Q12 of Q15
LLD - Design — Parking Lot System
Which of the following is the correct way to represent a parking spot in a class diagram?
Aclass Vehicle { int spotNumber; boolean isOccupied; }
Bclass Spot { int spotNumber; boolean isOccupied; }
Cclass Floor { int spotNumber; boolean isOccupied; }
Dclass ParkingLot { int spotNumber; boolean isOccupied; }
Step-by-Step Solution
Solution:
  1. Step 1: Identify the class representing a parking spot

    The Spot class should have attributes like spotNumber and isOccupied to represent a parking space.
  2. Step 2: Check other classes for correctness

    Vehicle represents cars, Floor represents a level, and ParkingLot represents the whole area, so they should not have spotNumber or isOccupied attributes.
  3. Final Answer:

    class Spot { int spotNumber; boolean isOccupied; } -> Option B
  4. Quick Check:

    Spot class holds spot info = A [OK]
Quick Trick: Spot class holds spot details like number and occupancy [OK]
Common Mistakes:
MISTAKES
  • Assigning spot attributes to Vehicle
  • Putting spotNumber in Floor or ParkingLot
  • Confusing class roles in diagram

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes