Requirements

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


Here are the requirements:

1) System needs to keep track of available spaces

2) System needs to keep track of parking durations for fee calculation



Define Core Objects

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


Vehicle:

-attributes:

  • type (ENUM)
  • vehicle id (int)


Spot:

-attributes:

  • spotid (int)
  • size (ENUM)
  • isOccupied (bool)
  • parkedAt (datetime)


Floor

-attributes:

  • floorid (int)
  • spotList (array of Spots)
  • vacantSpots (map of sets of indices of vacant spots in spotList mapped to different sizes)


ParkingLot

-attributes:

  • floorList (array of Floors)
  • vacantFloors (map of sets of indices of floors in floorList with at least one empty spot for a given size)


Analyze Relationships

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


Spot:

-methods:

  • occupy(datetime currenttime,Vehicle vehicle) : returns none
  • release(datettime currenttime) : returns -1 if empty else fee

Floor

-methods

  • getVacancy(ENUM size): returns None if all occupied else Spot for said size


ParkingLot

-methods

  • getVacancy(ENUM size): returns None if all occupied else Spot from first floor with vacancy for given size
  • getVacancy(ENUM size,int floorid): overloaded method returns None if all occupied else Spot from given floor with vacancy for given size




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...



utilized polymorphism to overload getVacancy() function for ParkingLot


Design Patterns

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






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.


from enum import Enum class VehicleType(Enum): CAR=0 TRUCK=1 BIKE=2 class Vehicle: count=0 # static variable to assign ids def __init__(self,VehicleType type): self.vehicleid=count count+=1 self.type=type class


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...