Course Content
Data Structures & Algorithms
Full Stack Web Development
Understanding and playing with DOM (Document Object Model)
0/2
MERN project
0/2
Low Level System Design
LLD Topics
High Level System Design
Fast-Track to Full Spectrum Software Engineering
Class Diagram – Car Parking 

Class Diagram models the static structure of the system by representing classes, their attributesmethods, and relationships. It helps students understand object-oriented principles such as inheritancecomposition, and associations in the context of the Car Parking domain.



1. Major Classes and Their Responsibilities

Below are the core classes identified in a typical Car Parking System:



A. ParkingLot

Attributes:

  • lotId: int
  • location: String
  • capacity: int
  • availableSlots: int

 

Methods:

  • getAvailableSlots(): int
  • updateSlotAvailability(): void

 

B. ParkingSlot

Attributes:

  • slotId: int
  • isOccupied: boolean
  • vehicleType: String
  • floorNumber: int

 

Methods:

  • assignVehicle(vehicle: Vehicle): void
  • vacateSlot(): void


C. Vehicle

Attributes:

  • vehicleNumber: String
  • ownerName: String
  • vehicleType: String

 

Methods:

  • getDetails(): String


D. Ticket

Attributes:

  • ticketId: int
  • entryTime: DateTime
  • exitTime: DateTime
  • slot: ParkingSlot
  • vehicle: Vehicle

 

Methods:

  • calculateDuration(): int
  • generateTicket(): void

 

E. Payment

Attributes:

  • paymentId: int
  • ticket: Ticket
  • amount: double
  • paymentMethod: String
  • paymentStatus: String

 

Methods:

  • processPayment(): boolean
  • generateReceipt(): String


F. User (Abstract Class)

Attributes:

  • userId: int
  • name: String
  • contactInfo: String

 

Methods:

  • login(): boolean


G. Driver (Extends User)

Attributes:

  • membershipId: String

 

Methods:

  • requestSlot(): Ticket
  • payForParking(): Payment


H. Admin (Extends User)

Methods:

  • configureRates(): void
  • generateReports(): List
  • monitorLotStatus(): void

 

I. Sensor

Attributes:

  • sensorId: int
  • type: String (e.g., motion, barrier)
  • status: boolean

 

Methods:

  • detectVehicle(): boolean
  • updateSystem(): void


2. Relationships Between Classes

  • ParkingLot contains multiple ParkingSlots (Composition)
  • ParkingSlot has one Vehicle (Aggregation)
  • Vehicle is associated with one Ticket
  • Ticket is linked to one Payment
  • User is the base class for both Driver and Admin (Inheritance)
  • Sensor interacts with ParkingSlot and ParkingLot


3. How to Explain This in Class

  • Start by identifying real-world entities and map them to classes.
  • Explain attributes as properties and methods as behaviors.
  • Emphasize relationships like composition (ParkingLot → ParkingSlot) and inheritance (User → Driver/Admin).
  • Demonstrate how new classes can be easily added without breaking existing design (Open/Closed Principle).
  • Optionally, draw the UML diagram using boxes and arrows to visually reinforce the structure.
0% Complete
WhatsApp Icon

Hi Instagram Fam!
Get a FREE Cheat Sheet on System Design.

Hi LinkedIn Fam!
Get a FREE Cheat Sheet on System Design

Loved Our YouTube Videos? Get a FREE Cheat Sheet on System Design.