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.
- 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
- Java 17+
- Maven
- PostgreSQL
- JDBC
- Java Date/Time API
- Object-Oriented Programming
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
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.
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
Before running the project, make sure you have:
- Java JDK 17 or higher
- Apache Maven 3.8+
- PostgreSQL 12 or higher
Make sure PostgreSQL is installed and running.
Create the database:
CREATE DATABASE smart_parking;Run the provided SQL file:
psql -U postgres -d smart_parking -f schema.sqlYou can also open schema.sql in pgAdmin and execute it using the Query Tool.
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";From the project root directory, run:
mvn clean compileRun the application using:
mvn exec:javaYou can also run the Main class directly from your Java IDE.
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.
The application currently supports:
| Vehicle | Description |
|---|---|
| Bike | Two-wheeler |
| Car | Four-wheeler |
| Truck | Large vehicle |
Different vehicle types can have different parking charges.
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.
You can test the application using the following flow.
- Start the application.
- Select Park Vehicle.
- Select a vehicle type.
- Enter the vehicle number.
- Confirm the parking operation.
- Check the assigned slot.
Expected result:
Vehicle parked successfully.
After parking a vehicle, select:
View Parking Slot Status
The assigned slot should show as occupied.
- Select Exit Vehicle.
- Enter the vehicle number.
- The application calculates the parking duration.
- The applicable parking fee is displayed.
- The parking slot becomes available again.
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.
You can verify the stored information using PostgreSQL:
SELECT * FROM parking_slots;
SELECT * FROM parking_records;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.
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
Bhaskar
Java project developed for learning and interview preparation.