A command-line based Hotel Reservation Application built in Java following Object-Oriented Programming (OOP) principles and a layered architecture. The application allows customers to create accounts, search for available rooms, make reservations, and enables administrators to manage rooms, customers, and reservations.
- Create a customer account
- Search for available rooms
- Reserve a room
- View personal reservations
- Receive recommended room availability if the selected dates are unavailable
- View all customers
- View all rooms
- View all reservations
- Add paid or free rooms
- Prevent duplicate room creation
The application follows a layered architecture to maintain separation of concerns.
Hotel Reservation Application
β
βββ UI Layer
β βββ MainMenu
β βββ AdminMenu
β
βββ API Layer
β βββ HotelResource
β βββ AdminResource
β
βββ Service Layer
β βββ CustomerService
β βββ ReservationService
β
βββ Model Layer
βββ Customer
βββ IRoom
βββ Room
βββ FreeRoom
βββ Reservation
βββ RoomType
HotelReservationApplication/
β
βββ api/
β βββ AdminResource.java
β βββ HotelResource.java
β
βββ model/
β βββ Customer.java
β βββ FreeRoom.java
β βββ IRoom.java
β βββ Reservation.java
β βββ Room.java
β βββ RoomType.java
β
βββ service/
β βββ CustomerService.java
β βββ ReservationService.java
β
βββ AdminMenu.java
βββ MainMenu.java
βββ HotelApplication.java
- Java
- Object-Oriented Programming (OOP)
- Collections Framework
- Regular Expressions (Regex)
- Date & Calendar API
- Command Line Interface (CLI)
- Encapsulation
- Abstraction
- Inheritance
- Polymorphism
- Interfaces
- Singleton Design Pattern
- Layered Architecture
- First Name
- Last Name
- Email Validation using Regex
- Room Number
- Price
- Room Type
- Extends
Room - Automatically sets room price to
0
- Customer
- Room
- Check-in Date
- Check-out Date
Enumeration containing:
- SINGLE
- DOUBLE
Interface defining room behavior.
Handles customer-related operations:
- Add customer
- Get customer
- Retrieve all customers
Handles reservation-related operations:
- Add room
- Get room
- Reserve room
- Search available rooms
- Search recommended rooms
- View customer reservations
- Display all reservations
Acts as an intermediary between the UI and services.
Functions include:
- Create customer
- Find room
- Reserve room
- Get customer reservations
Provides administrative operations:
- Add rooms
- View all rooms
- View all customers
- View all reservations
1. Find and reserve a room
2. See my reservations
3. Create an account
4. Admin
5. Exit
1. See all Customers
2. See all Rooms
3. See all Reservations
4. Add a Room
5. Back to Main Menu
- Email format validation using Regular Expressions
- Prevent duplicate customer accounts
Example:
user@example.com
- Room number cannot be empty
- Room numbers must be unique
- Room price cannot be negative
- Room type validation (SINGLE or DOUBLE only)
- Check-in date cannot be in the past
- Check-out date must be after check-in date
- Minimum stay of one day
- Prevent overlapping reservations
- Prevent double booking
The application searches available rooms based on:
- Check-in Date
- Check-out Date
If rooms are unavailable, the application automatically searches for available rooms 7 days later and recommends them to the user.
Example:
Requested:
10 Apr β 12 Apr
Recommended:
17 Apr β 19 Apr
Users can directly reserve the recommended room.
The application supports free rooms using inheritance.
Features:
- Price automatically set to βΉ0
- Displayed as Free
- Available during room searches
- Can be reserved like any other room
| Data | Collection |
|---|---|
| Customers | HashMap |
| Rooms | HashMap |
| Reservations | ArrayList |
Implemented in:
- CustomerService
- ReservationService
- HotelResource
- AdminResource
Ensures only one instance of each service/resource exists throughout the application.
The application gracefully handles invalid inputs using:
- try-catch blocks
- IllegalArgumentException
Examples:
- Invalid email
- Duplicate room
- Duplicate customer
- Invalid room type
- Invalid reservation dates
- Room already booked
Create Account
β
Search Rooms
β
Select Room
β
Reserve Room
β
View Reservation
Login Admin Menu
β
Add Rooms
β
View Customers
β
View Rooms
β
View Reservations
- Clone the repository
git clone https://github.com/your-username/hotel-reservation-application.git-
Open the project in IntelliJ IDEA (or any Java IDE).
-
Run:
HotelApplication.java
This project demonstrates practical implementation of:
- Java Fundamentals
- Object-Oriented Programming
- Interfaces and Inheritance
- Polymorphism
- Collections Framework
- Singleton Design Pattern
- Layered Architecture
- Exception Handling
- Input Validation
- Command Line Applications
- Date and Calendar Operations
- Database integration (MySQL/PostgreSQL)
- Spring Boot REST API
- Authentication & Authorization
- Room cancellation
- Payment integration
- Room categories and pricing
- JUnit testing
- Logging framework
- File-based or database persistence
Ajay
Backend Developer | Java | Spring Boot | SQL