Skip to content

RiyaBhurse/ParkingLotLLD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš— Parking Lot Management System

A comprehensive Low-Level Design (LLD) implementation of a parking lot management system built in Java, following Object-Oriented Programming principles and design patterns.

πŸ“‹ Table of Contents

🎯 Overview

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.

Key Objectives

  • 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

✨ Features

Core Functionality

  • βœ… 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

Advanced Features

  • πŸ”‹ 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

πŸ—οΈ System Requirements

Functional Requirements

  1. Vehicle Parking: System should assign nearest available slot based on vehicle size
  2. Ticket Generation: Generate unique tickets with entry time and slot information
  3. Bill Calculation: Calculate parking fees based on duration and slot type
  4. Multiple Gates: Support multiple entry and exit points
  5. Slot Management: Track slot availability and vehicle accommodation rules

Non-Functional Requirements

  • 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

πŸ›οΈ Architecture & Design Patterns

Design Patterns Used

1. Strategy Pattern

  • Purpose: Flexible billing calculations
  • Implementation: BillingStrategy interface 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();
}

2. Builder Pattern

  • Purpose: Flexible vehicle creation
  • Implementation: Vehicle.Builder for optional parameters
  • Benefits: Clean object construction with optional electric charging
Vehicle car = new Vehicle.Builder("ABC123", VehicleSize.MEDIUM)
    .withElectricCharging()
    .build();

3. Factory Pattern (Implicit)

  • Purpose: Slot type creation
  • Implementation: Different slot classes implementing ParkingSlot interface
  • Benefits: Polymorphic slot behavior

SOLID Principles

  • 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

πŸ”§ Core Components

1. ParkingLot (Main Orchestrator)

  • Manages floors, gates, and active tickets
  • Coordinates vehicle parking and removal operations
  • Provides system-wide status information

2. Vehicle Management

  • Vehicle: Represents parked vehicles with builder pattern
  • VehicleSize: Enum defining size categories (SMALL, MEDIUM, LARGE, EXTRA_LARGE)

3. Slot Management

  • ParkingSlot: Interface defining slot behavior
  • Concrete Implementations: SmallSlot, MediumSlot, LargeSlot, ExtraLargeSlot
  • Features: Size-based accommodation, electric charging support, distance tracking

4. Gate System

  • EntryGate: Handles vehicle entry and ticket generation
  • ExitGate: Manages vehicle exit and bill generation
  • Distance-Based Allocation: Finds nearest available slots

5. Billing System

  • BillingStrategy: Interface for different pricing models
  • StandardBillingStrategy: Basic hourly rate calculation with electric charging fees

6. Ticketing System

  • Ticket: Contains vehicle and parking information
  • Bill: Detailed billing information with strategy used

πŸš€ Installation & Setup

Prerequisites

  • Java 8 or higher
  • Git (for cloning the repository)

Clone the Repository

git clone git@github.com:RiyaBhurse/ParkingLotLLD.git
cd ParkingLotLLD

Compile the Project

# Navigate to src directory
cd src

# Compile all Java files
javac *.java

# Run the main application
java ParkingLot

πŸ’‘ Usage Examples

Basic Usage

// 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());

Advanced Features

// 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());

🎯 Design Decisions

Distance Calculation

  • 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

Slot Allocation Strategy

  • 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

Billing Strategy Selection

  • Design: Strategy pattern with multiple implementations
  • Flexibility: Easy addition of new pricing models
  • Examples: Standard, Weekend Premium, VIP Discount

Data Structures

  • List: For storing slots, floors, gates (simple iteration needed)
  • HashMap: For active ticket management (O(1) lookup)
  • Builder Pattern: For optional vehicle parameters

πŸ”„ Extensibility

Adding New Slot Types

public class CompactSlot implements ParkingSlot {
    // Implementation for compact vehicle slots
}

Adding New Billing Strategies

public class HourlyDiscountBillingStrategy implements BillingStrategy {
    public double calculateAmount(Ticket ticket, LocalDateTime exitTime) {
        // Custom pricing logic
    }
}

Adding New Vehicle Types

// Extend VehicleSize enum
public enum VehicleSize {
    SMALL, MEDIUM, LARGE, EXTRA_LARGE, MOTORCYCLE, TRUCK
}

πŸ“ Project Structure

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

🀝 Contributing

We welcome contributions to improve the parking lot management system!

How to Contribute

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/new-feature)
  3. Make your changes following the existing code style
  4. Add tests for new functionality
  5. Commit your changes (git commit -am 'Add new feature')
  6. Push to the branch (git push origin feature/new-feature)
  7. Create a Pull Request

Contribution Guidelines

  • Follow existing naming conventions
  • Maintain SOLID principles
  • Add appropriate documentation
  • Ensure backward compatibility
  • Write clear commit messages

πŸ“§ Contact

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages