Skip to content

Latest commit

ย 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš— Smart Parking Lot Management System

A Java-based parking lot management application that helps manage parking slots, vehicles, parking sessions, and parking fees.

The application provides a simple console interface and uses PostgreSQL to store parking and vehicle-related information.


โœจ Features

  • Park different types of vehicles
  • Assign available parking slots
  • View current parking slot status
  • Remove vehicles from the parking lot
  • Calculate parking fees
  • Store parking records in PostgreSQL
  • Handle situations when parking slots are unavailable
  • Simple interactive console menu

๐Ÿ› ๏ธ Technologies Used

  • Java 17+
  • Maven
  • PostgreSQL
  • JDBC
  • Java Date/Time API
  • Object-Oriented Programming

๐Ÿ“‚ Project Structure

smart-parking/
โ”œโ”€โ”€ pom.xml
โ”œโ”€โ”€ schema.sql
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ src/main/java/com/smartparking/
    โ”œโ”€โ”€ model/
    โ”‚   โ”œโ”€โ”€ Vehicle.java
    โ”‚   โ”œโ”€โ”€ Bike.java
    โ”‚   โ”œโ”€โ”€ Car.java
    โ”‚   โ”œโ”€โ”€ Truck.java
    โ”‚   โ”œโ”€โ”€ ParkingRecord.java
    โ”‚   โ”œโ”€โ”€ VehicleType.java
    โ”‚   โ””โ”€โ”€ SlotStatus.java
    โ”œโ”€โ”€ strategy/
    โ”‚   โ”œโ”€โ”€ FeeStrategy.java
    โ”‚   โ”œโ”€โ”€ BikeFeeStrategy.java
    โ”‚   โ”œโ”€โ”€ CarFeeStrategy.java
    โ”‚   โ””โ”€โ”€ TruckFeeStrategy.java
    โ”œโ”€โ”€ exception/
    โ”‚   โ””โ”€โ”€ ParkingFullException.java
    โ”œโ”€โ”€ db/
    โ”‚   โ””โ”€โ”€ DBConnection.java
    โ”œโ”€โ”€ dao/
    โ”‚   โ””โ”€โ”€ ParkingDAO.java
    โ”œโ”€โ”€ service/
    โ”‚   โ””โ”€โ”€ ParkingService.java
    โ””โ”€โ”€ Main.java

Main Components

Model Contains the classes used to represent vehicles, parking records, and parking statuses.

Service Handles the main parking operations and application logic.

DAO Handles communication with the PostgreSQL database.

Strategy Contains the fee calculation logic for different vehicle types.

Exception Contains custom application exceptions.

DB Manages the database connection.

Main Provides the console-based user interface.


๐Ÿ—„๏ธ Database

The application uses PostgreSQL to store parking information.

The database contains tables for:

  • Parking slots
  • Parking records

The database setup is available in:

schema.sql

๐Ÿ› ๏ธ Requirements

Before running the project, make sure you have:

  • Java JDK 17 or higher
  • Apache Maven 3.8+
  • PostgreSQL 12 or higher

๐Ÿš€ How to Run

1. Create the Database

Make sure PostgreSQL is installed and running.

Create the database:

CREATE DATABASE smart_parking;

2. Apply the Database Schema

Run the provided SQL file:

psql -U postgres -d smart_parking -f schema.sql

You can also open schema.sql in pgAdmin and execute it using the Query Tool.


3. Configure Database Connection

The application connects to:

jdbc:postgresql://localhost:5432/smart_parking

The default database user is:

postgres

If your PostgreSQL username or password is different, update the database configuration in:

src/main/java/com/smartparking/db/DBConnection.java

Example:

private static final String DEFAULT_URL =
        "jdbc:postgresql://localhost:5432/smart_parking";

private static final String DEFAULT_USER = "postgres";

private static final String DEFAULT_PASSWORD =
        "YOUR_POSTGRES_PASSWORD";

4. Build the Project

From the project root directory, run:

mvn clean compile

5. Run the Application

Run the application using:

mvn exec:java

You can also run the Main class directly from your Java IDE.


๐Ÿ“‹ Application Flow

The application provides a console menu for common parking operations.

A typical flow is:

1. Park Vehicle
2. Exit Vehicle
3. View Parking Slot Status
4. Exit

The exact menu options may vary depending on the current version of the application.


๐Ÿš˜ Supported Vehicles

The application currently supports:

Vehicle Description
Bike Two-wheeler
Car Four-wheeler
Truck Large vehicle

Different vehicle types can have different parking charges.


๐Ÿ’ฐ Parking Fees

The application calculates parking fees based on:

  • Vehicle type
  • Parking duration
  • Applicable free parking time
  • Vehicle-specific hourly charges

For example, the current configuration provides a short free period before hourly charges are applied.

The exact rates can be adjusted in the fee calculation classes.


๐Ÿงช Basic Testing

You can test the application using the following flow.

Test 1: Park a Vehicle

  1. Start the application.
  2. Select Park Vehicle.
  3. Select a vehicle type.
  4. Enter the vehicle number.
  5. Confirm the parking operation.
  6. Check the assigned slot.

Expected result:

Vehicle parked successfully.

Test 2: View Parking Status

After parking a vehicle, select:

View Parking Slot Status

The assigned slot should show as occupied.


Test 3: Exit a Vehicle

  1. Select Exit Vehicle.
  2. Enter the vehicle number.
  3. The application calculates the parking duration.
  4. The applicable parking fee is displayed.
  5. The parking slot becomes available again.

Test 4: Full Parking Lot

Park vehicles until the available slots are occupied.

When no suitable slot is available, the application displays an appropriate message instead of assigning an unavailable slot.


Test 5: Database Records

You can verify the stored information using PostgreSQL:

SELECT * FROM parking_slots;

SELECT * FROM parking_records;

๐ŸŽฏ Project Purpose

This project was created as a practical Java application for learning and interview preparation.

It focuses on building a small application that combines:

  • Object-oriented programming
  • Database operations
  • Basic business logic
  • Date and time calculations
  • Exception handling
  • Console-based interaction

The project is intentionally kept as a simple standalone application rather than a large production system.


๐Ÿ”ฎ Possible Improvements

Future versions could include:

  • Web-based interface
  • User authentication
  • Online payment support
  • Parking availability dashboard
  • Search and filtering
  • Daily/monthly parking reports
  • Automatic notifications
  • Better configuration management

๐Ÿ‘จโ€๐Ÿ’ป Author

Bhaskar

Java project developed for learning and interview preparation.

About

๐Ÿš— Smart Parking Lot Management System

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages