Parking Lot System Design | Object-Oriented Design Interview Question

Requirements

  • 10K to 30K parking slots.
  • Assume there are 4 entrances and 4 exits.
  • Ticket and spot allocated at the entrance.
  • The spot should be near the entrance the user entered.
  • Different types of spots for bike, handicap, cars, truck.
  • Hourly parking rate.
  • Pay parking fee using cash and cards.
  • Monitoring system for total cars entered etc.

Different actors

  • Parking lot system
  • Entry/exit terminal
  • Printer
  • Payment processor
  • Parking spot
  • Ticket
  • Database
  • Monitoring system

 Parking spot

  1. Parent class parking spot
  2. Child class handicapped parking spot
  3. Child class car parking spot
  4. Child class truck parking spot

 Ticket

  1. Ticket class
  2. Ticket id
  3. Parking spot id
  4. Parking spot type
  5. Issue time

 Terminal

  1. Parent class terminal
  2. Child class entry terminal: getTicket(parkingSpotType)
  3. Child class exit terminal: acceptTicket(ticket)

 Parking assignment strategy

  1. Class Parking assignment strategy
  2. Get parking spot method
  3. Release parking spot method
  4. Since we have 4 entrances we will have 4 heaps.
  5. Once a parking spot is reserved make sure you to remove it from all the 4 heaps.

Payment

  1. Parent class Payment processor
  2. Child class credit card payment processor
  3. Child class cash payment processor

Tariff calculator

  • Calculate tariff method(start time,  parking spot type)

Monitoring system

  • Use logger

Parking lot application

  • This application uses a singleton design system.
  • Will be composed of above smaller objects.
  • Use a factory design pattern to instantiate above smaller objects.
  • Application accept XML configuration as input. Input like parking spot type,  payment type.

About siddarth

An average student from PSG College of Technology with an aim to become an omniscient in the field of technology.
This entry was posted in System design. Bookmark the permalink.

2 Responses to Parking Lot System Design | Object-Oriented Design Interview Question

  1. siddarth says:

    Remember the pattern – stampped
    1 strategy
    2 ticket
    3 application
    4 monitoring
    5 processor
    6 printer
    7 entry/exit terminal
    8 database

    Like

  2. siddarth says:

    Try using the following pattern

    1 input classes
    2 output classes
    3 service classes
    4 database classes
    5 application & configuration
    6 monitoring&logging

    For ATM

    1. input – admin
    AdminInput – adminUserId, adminOTP, totalInputCash, dbUpdate()
    2. input – customer
    CustomerInput – userCard, userId, userPin, userOtp, cashNeeded
    userCardBase – visaChild, masterCardChild
    3 Output
    Printer bool Print()
    Receipt – accountNumber, balance, amountTaken, dateTime
    cardEjector
    cashEjector
    4 Service
    UserValidation – chain pattern (verify card, verify pin, verify otp, verify balance)
    AmountValidation – chain pattern (bank balance validation, available denomination validation)
    AdminValidation – chain pattern
    CashTrayCalculator
    5 Database
    CashTray[] (100, 200, 500)
    CRUD
    6 Application – singleton, factory pattern
    7 Monitoring

    Like

Leave a comment