Requirements

Determine the different ways the system will be used. This includes main functions the system needs to perform and who will use it.

1) Include multiple level of building floors which means having including multiple list inside a list in Java

2) For each list in Java or building floor, we define a class VehicleData which includes vehicle size - Small, Medium and Big and availability of space for medium and big vehicles and parked duration of the vehicle. This List Data type will of this class type VehicleData




Define Core Objects

Based on the requirements and use cases, identify the main objects of the system...

1) Parking Lot Class contains

a) ParkingFloor Class - contains methods for available floor, add floor and allot vehicle size parking quantity for each floor

b) Vehicle Data - contains method for checking vehicle size - small, medium and large and track global quantity of vehicle for each size

c) ParkingSpot Class - contains methods for each floor, we check available spot for Small and Large Size vehicles and allot or not allot base on availability. If we allot, we catch the timestamp and add the quantity of vehicle size and decrease the allotment quantity

d) Parking Fee Calculator - We check for each vehicle how much time we charge for Small, medium and large size vehicles based on time. Time will be current timestamp - timestamp when the vehicle was parked




Analyze Relationships

Determine how these objects will interact with each other to fulfill the use cases...

  1. Composition: Parking Lot contains Parking Floor
  2. Aggregation: ParkingFloor contains Parking Spot
  3. Association: ParkingSpot contains VehicleData
  4. Dependencies: ParkingFeeCalculator depends on VehicleData
  5. Inheritance: We may built a base class Vehicle and create class like electric cars, SUV based on Vehicle




Establish Hierarchy

Design inheritance trees where applicable to promote code reuse and polymorphism. This step involves identifying common attributes and behaviors that can be abstracted into parent classes...

Vehicle Class

  • String licenseNumber
  • String vehicleType
  • DateTime arrivalTime
  • park
  • unpark

Car Inherit vehicle class

  • carType

Truck inherits vehicle class

  • loadCapactiy

Electric vehicle inherits vehicle class

  • int batteryLevel




Design Patterns

Consider using design patterns (e.g., Factory, Singleton, Observer, Strategy) that fit the problem...

  • Singleton Pattern: Parking lot
  • Factory pattern: create instances of different vehicle types
  • Observer pattern: ParkingSpot status updates




Define Class Members (write code)

Attributes: For each class, define the attributes (data) it will hold...

Methods: Define the methods (functions) that operate on the attributes. Ensure they align with the object's responsibilities and adhere to the principle of encapsulation.


public class Car { ... } // Example





Adhere to SOLID Guidelines

Check and explain whether your design adheres to solid principles (Ask interviewer what SOLID principle is if you can not recall it.)...






Consider Scalability and Flexibility

Explain how your design can handle changes in scale and whether it would be easily to extend with new functionalities...






Create/Explain your diagram(s)

Try creating a class, flow, state and/or sequence diagram using the diagramming tool. Mermaid flow diagrams can be used to represent system use cases. You can ask the interviewer bot to create a starter diagram if unfamiliar with the tool. Briefly explain your diagrams if necessary...






Future improvements

Critically examine your design for any flaws or areas for future improvement...