Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hotel Management System

A menu-driven Java console application for managing hotel room bookings, check-ins, and check-outs — with dual persistence to MySQL and flat files.

Java MySQL Interface

Overview

This project simulates the day-to-day front-desk operations of a small hotel with 10 rooms. It demonstrates core object-oriented programming concepts — inheritance, polymorphism, and encapsulation — through a room class hierarchy, and integrates with a MySQL database via JDBC while also writing human-readable records to text files.

Features

  • Room catalog with inheritance — a base Room class extended by StandardRoom ($100/night), DeluxeRoom ($150/night), and SuiteRoom ($200/night)
  • Room booking with guest details, check-in date, and stay duration
  • Check-in / check-out flow with total cost calculated as price x nights
  • Live room status display showing type, price, availability, and current guest
  • Robust input validation — guest names (alphabetic, min 2 chars), contact numbers (exactly 10 digits), ISO dates (YYYY-MM-DD, no past dates), and positive stay durations
  • Dual persistence
    • Bookings inserted into a MySQL bookings table via JDBC PreparedStatement
    • Bookings appended to booking_data.txt; room status snapshot written to room_status.txt on exit

Project Structure

Hotelmanagement/
├── management/
│   ├── HotelManagementSystem.java   # Main class: menu loop, DB + file persistence
│   └── mysql-connector-j-8.2.0.jar  # JDBC driver
├── room/
│   ├── Room.java                    # Base class: booking, check-in/out, cost logic
│   ├── StandardRoom.java            # $100/night
│   ├── DeluxeRoom.java              # $150/night
│   ├── SuiteRoom.java               # $200/night
│   └── CheckIn.java                 # Check-in date + stay duration
├── booking_data.txt                 # Sample booking records
└── room_status.txt                  # Sample room status snapshot

Tech Stack

  • Java (java.time, java.io, JDBC)
  • MySQL with MySQL Connector/J 8.2.0
  • File I/O for plain-text record keeping

Getting Started

Prerequisites

  • JDK 8+
  • A running MySQL server

Database setup

Create the database and table expected by the app:

CREATE DATABASE hotelmanagementsystem;
USE hotelmanagementsystem;

CREATE TABLE bookings (
    room_number   INT,
    guest_name    VARCHAR(100),
    guest_contact VARCHAR(10),
    check_in_date DATE,
    stay_duration INT
);

Update DB_URL, DB_USERNAME, and DB_PASSWORD in management/HotelManagementSystem.java to match your local MySQL credentials.

Compile and run

From the repository root:

javac -cp management/mysql-connector-j-8.2.0.jar management/HotelManagementSystem.java room/*.java
java -cp .:management/mysql-connector-j-8.2.0.jar management.HotelManagementSystem

(On Windows, use ; instead of : in the classpath.)

Then follow the on-screen menu:

Hotel Management System Menu:
1. Display Room Status
2. Book a Room
3. Check In
4. Check Out
5. Exit

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages