LLD of Car Rental System
Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2024-12-23
Problem Statement
Design a Car Rental System that allows users to search, book, and manage car rentals while handling car availability, booking, and optionally payments. The focus is on object-oriented design, modularity, and real-world constraints.
Functional Requirements
1.Car Management
•Maintain a catalog of cars with attributes: id, brand, model, type, registrationNumber, availability.
•Support adding, removing, and updating car details (admin functionality).
2.User Management
•Users can register, login, and update profiles.
•Users can search for cars, book cars, and cancel bookings.
3.Booking Management
•Users can search cars by type, brand, and availability for a time slot.
•Bookings are confirmed only if the car is available.
•Support booking cancellation and modification.
4.Optional Features
•Associate payment with bookings.
•Support multiple locations or dynamic pricing.
Constraints & Assumptions
•Time slots represented with start and end timestamps.
•Thread-safety optional unless multiple users access the system concurrently.
•Focus on LLD and OOP design, not UI or payment integration.
Key Components / Classes
•Car → stores car details and availability.
•User → stores user information and interacts with bookings.
•Booking → stores booking details, associated user, car, and time slot.
•CarRentalSystem → controller managing cars, bookings, and searches.
•TimeSlot → represents booking period and checks for overlaps.
Example Workflow
1.User searches for available cars for a given time slot.
2.System returns cars that are available.
3.User books a car → system verifies availability → booking confirmed.
4.User can cancel or modify booking.
5.Admin can add or update car information.