Problem details

A parking lot is a designated area for parking vehicles, commonly found at venues like malls, stadiums, and offices. It has a fixed number of spots for different vehicle types, with charges based on parking duration. Time is tracked via a ticket issued at entry, and payment can be made at exit via card or cash.

dns-hierarchy

Expectations from the interviewee:

  1. Vehicle types: Handling different vehicle types—car, truck, van, motorcycle—which can have the following set of questions
    • How will capacity be allocated for different vehicle types?
    • If the parking spot of any vehicle type is booked, can a vehicle of another type park in the designated parking spot?
  2. Parking spot type:
  3. Another important area of discussion that the interviewer may expect you to be familiar with is the different types of parking spots—such as handicapped, compact, large, and motorcycle spots. Here are some key questions you might consider:
    • How will the parking capacity for each type of spot be determined?
    • What should happen when a particular section of the parking lot becomes full?
    • How can the system efficiently track available parking spots across multiple floors if the lot has more than one level?
    • How will the parking spots be allocated among the four different types within the lot?
  4. Payment flexibility:
  5. The payment structure is a crucial aspect of the parking lot system. The interviewer may expect you to consider questions such as:
    • How can customers pay at different exit points using various methods (cash, credit, coupon)?
    • In a multi-floor parking lot, how will the system track if a customer has already paid on a specific floor rather than at the exit?
  6. Pricing:
  7. To clarify the pricing model, you might ask:
    • How will pricing be structured? Should we implement different rates by the hour, like $4 for the first hour, $3.5 for the next two hours, and $2.5 for each additional hour?
    • Will the pricing differ based on vehicle type?
  8. Design approach:
  9. We'll design the parking lot system using a bottom-up approach:
    • Start by designing the smallest components, such as vehicle and parking spot types.
    • Use these to build larger components, like the payment system at the exit.
    • Continue this process until the entire system, including the parking lot, is designed.
  10. Design pattern:


Requirements:


Use Case Diagram

dns-hierarchy

Class Diagram

dns-hierarchy

Sequence Diagram

dns-hierarchy