A comprehensive Low-Level Design (LLD) implementation of a parking lot management system built in Java, following Object-Oriented Programming principles and design patterns.
- Overview
- Features
- System Requirements
- Architecture & Design Patterns
- Core Components
- Installation & Setup
- Usage Examples
- Design Decisions
- Extensibility
- Contributing
This parking lot management system is designed to handle the core functionalities of a multi-floor parking facility with multiple entry/exit gates. The system generates tickets upon vehicle entry and calculates bills based on parking duration, slot type, and various billing strategies.
- Scalability: Support for multiple floors, gates, and slot types
- Flexibility: Easy addition of new vehicle sizes, slot types, and billing strategies
- Maintainability: Clean separation of concerns and SOLID principles
- Efficiency: Optimized slot allocation based on distance from entry gates
- β Vehicle Entry Management: Automatic ticket generation with nearest slot allocation
- β Vehicle Exit Management: Bill generation with configurable billing strategies
- β Multi-Floor Support: Unlimited floors with customizable slot configurations
- β Multiple Gates: Support for multiple entry and exit gates
- β Real-time Status: Live parking lot occupancy tracking
- π Electric Vehicle Support: Dedicated charging slots with additional fees
- π° Flexible Billing: Strategy pattern implementation for different pricing models
- π Distance-Based Allocation: Nearest available slot assignment
- π« Comprehensive Ticketing: Detailed ticket information with vehicle data
- π Extensible Design: Easy addition of new features and components
- Vehicle Parking: System should assign nearest available slot based on vehicle size
- Ticket Generation: Generate unique tickets with entry time and slot information
- Bill Calculation: Calculate parking fees based on duration and slot type
- Multiple Gates: Support multiple entry and exit points
- Slot Management: Track slot availability and vehicle accommodation rules
- Performance: O(log n) slot allocation using efficient data structures
- Scalability: Support for hundreds of parking slots and multiple floors
- Maintainability: Modular design with clear separation of concerns
- Extensibility: Easy addition of new slot types and billing strategies
- Purpose: Flexible billing calculations
- Implementation:
BillingStrategyinterface with multiple concrete strategies - Benefits: Easy addition of new pricing models without modifying existing code
public interface BillingStrategy {
double calculateAmount(Ticket ticket, LocalDateTime exitTime);
String getStrategyName();
}- Purpose: Flexible vehicle creation
- Implementation:
Vehicle.Builderfor optional parameters - Benefits: Clean object construction with optional electric charging
Vehicle car = new Vehicle.Builder("ABC123", VehicleSize.MEDIUM)
.withElectricCharging()
.build();- Purpose: Slot type creation
- Implementation: Different slot classes implementing
ParkingSlotinterface - Benefits: Polymorphic slot behavior
- Single Responsibility: Each class has one reason to change
- Open/Closed: System is open for extension (new slot types, billing strategies)
- Liskov Substitution: All slot implementations are interchangeable
- Interface Segregation: Clean interfaces without forced dependencies
- Dependency Inversion: High-level modules don't depend on low-level modules
- Manages floors, gates, and active tickets
- Coordinates vehicle parking and removal operations
- Provides system-wide status information
- Vehicle: Represents parked vehicles with builder pattern
- VehicleSize: Enum defining size categories (SMALL, MEDIUM, LARGE, EXTRA_LARGE)
- ParkingSlot: Interface defining slot behavior
- Concrete Implementations: SmallSlot, MediumSlot, LargeSlot, ExtraLargeSlot
- Features: Size-based accommodation, electric charging support, distance tracking
- EntryGate: Handles vehicle entry and ticket generation
- ExitGate: Manages vehicle exit and bill generation
- Distance-Based Allocation: Finds nearest available slots
- BillingStrategy: Interface for different pricing models
- StandardBillingStrategy: Basic hourly rate calculation with electric charging fees
- Ticket: Contains vehicle and parking information
- Bill: Detailed billing information with strategy used
- Java 8 or higher
- Git (for cloning the repository)
git clone git@github.com:RiyaBhurse/ParkingLotLLD.git
cd ParkingLotLLD# Navigate to src directory
cd src
# Compile all Java files
javac *.java
# Run the main application
java ParkingLot// Create parking lot
ParkingLot parkingLot = new ParkingLot("City Center Parking");
// Add floors and slots
ParkingFloor floor1 = new ParkingFloor(1);
floor1.addParkingSlot(new SmallSlot("F1-S01", 2.0, false, 1, "A", 1));
parkingLot.addFloor(floor1);
// Add gates
parkingLot.addEntryGate(new EntryGate("ENTRY-01"));
parkingLot.addExitGate(new ExitGate("EXIT-01"));
// Park vehicle
Vehicle car = new Vehicle.Builder("ABC123", VehicleSize.SMALL).build();
Ticket ticket = parkingLot.parkVehicle(car);
// Generate bill
Bill bill = parkingLot.removeVehicle(ticket.getTicketId());// Electric vehicle with charging
Vehicle electricCar = new Vehicle.Builder("EV123", VehicleSize.MEDIUM)
.withElectricCharging()
.build();
// Bill includes electric charging fees automatically
Bill bill = parkingLot.removeVehicle(ticket.getTicketId());- Approach: Simple integer-based distance per gate-slot pair
- Rationale: Practical and efficient compared to coordinate-based calculations
- Implementation: Each slot maintains distance mapping for different gates
- Method: Iterate through sorted list to find nearest available slot
- Benefits: Simple, reliable, and easy to debug
- Time Complexity: O(n) for slot finding, acceptable for typical parking lot sizes
- Design: Strategy pattern with multiple implementations
- Flexibility: Easy addition of new pricing models
- Examples: Standard, Weekend Premium, VIP Discount
- List: For storing slots, floors, gates (simple iteration needed)
- HashMap: For active ticket management (O(1) lookup)
- Builder Pattern: For optional vehicle parameters
public class CompactSlot implements ParkingSlot {
// Implementation for compact vehicle slots
}public class HourlyDiscountBillingStrategy implements BillingStrategy {
public double calculateAmount(Ticket ticket, LocalDateTime exitTime) {
// Custom pricing logic
}
}// Extend VehicleSize enum
public enum VehicleSize {
SMALL, MEDIUM, LARGE, EXTRA_LARGE, MOTORCYCLE, TRUCK
}ParkingLot/
βββ src/
β βββ ParkingLot.java # Main orchestrator class
β βββ Vehicle.java # Vehicle representation with builder
β βββ VehicleSize.java # Vehicle size enumeration
β βββ ParkingSlot.java # Slot interface
β βββ SmallSlot.java # Small slot implementation
β βββ MediumSlot.java # Medium slot implementation
β βββ LargeSlot.java # Large slot implementation
β βββ ExtraLargeSlot.java # Extra large slot implementation
β βββ ParkingFloor.java # Floor management
β βββ EntryGate.java # Entry gate operations
β βββ ExitGate.java # Exit gate operations
β βββ Ticket.java # Ticket representation
β βββ Bill.java # Bill generation and management
β βββ BillingStrategy.java # Billing strategy interface
β βββ StandardBillingStrategy.java # Standard billing implementation
βββ README.md # Project documentation
βββ DISTANCE_SYSTEM.md # Distance calculation details
We welcome contributions to improve the parking lot management system!
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-feature) - Make your changes following the existing code style
- Add tests for new functionality
- Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature/new-feature) - Create a Pull Request
- Follow existing naming conventions
- Maintain SOLID principles
- Add appropriate documentation
- Ensure backward compatibility
- Write clear commit messages
Repository: https://github.com/RiyaBhurse/ParkingLotLLD
This project demonstrates practical application of Object-Oriented Design principles, design patterns, and Java programming best practices in building a scalable parking lot management system.