Requirements


Functional Requirements:


  • Assign parking spots based on vehicle size, allowing motorcycles to park in small spots, cars in medium spots, and trucks in large spots, with the option to park in larger spots if needed.
  • Issue a ParkingTicket upon vehicle entry, which records the vehicle information, assigned parking spot, and entry timestamp.
  • Compute the parking fee upon vehicle exit based on the duration of stay and a configurable pricing strategy.
  • Handle scenarios where the parking lot is full by rejecting entry and displaying a lot-full indicator to the driver.
  • Support multiple floors in the parking lot, with each floor containing a mix of small, medium, and large parking spots.


Core Objects & Relationships

Based on the requirements and use cases, identify the main objects of the system and analyze how they interact and relate to each other...


ParkingLot - represent system coordinator and manage state. Check the availabilities of each parkingSpots, handle vehicle park and exit.

ParkingSpot - represent parking spot metadata, including parking spot type (small, large, larger), occupied status, floor, charge unit.

Floor - represent floor metadata, including parkingSpots information

Vehicle - represent vehicle metadata, including vehicle type (motorcycle, car, truck)

Ticket - mange the parking session, record enter time, exit time, calculate the parking duration, calculate fees, parking spot.

Notification - notify the driver

People - driver, doorman





APIs & Class Members

For each class, define the attributes (data) it will hold and the methods (functions) that operate on the attributes. Ensure they align with the object's responsibilities and adhere to the principle of encapsulation. Write your code in the code editor below.



Deep Dive

Explain design tradeoffs you considered. Check and explain whether your design adheres to SOLID principles. Explain how your design can handle changes in scale and whether it would be easy to extend with new functionalities. Identify areas for future improvement...


My design:

  1. abstract People, ParkingSpot, which embody the abstraction, polymorphism OOP principles, and represents the open close principle, dependency inversion principle, Liskov Substitution principle
  2. Define ParkingLot, parkingSpot, Notify, Ticket etc classes which only represent single responsibilities.


For future improvement:

  1. we could use singleton design principle for creating the ParkingLot instance.
  2. Could use Observer design pattern for notification
  3. Could use Factory design pattern for creating parkingSpot based on different type of vehicle
  4. Could abstract the Vehicle classes if the vehicle contain quite complexed logic, so that we could extend the different type of vehicle easily.