A simple Java-based Bus Reservation System that allows users to book, cancel, and view seat reservations for buses. This project is designed to help beginners understand core Java concepts like Object-Oriented Programming (OOP), Collections, and Exception Handling.
- View All Buses: Display the list of available buses with their IDs and capacities.
- View Available Seats: Check the available seats for a specific bus.
- Book a Seat: Reserve a seat by entering passenger details (name, phone number).
- Cancel a Seat: Cancel a seat reservation by providing the seat number.
- View All Bookings: Display all bookings for a specific bus.
- Language: Java
- Core Concepts: Object-Oriented Programming (OOP), Collections (
HashMap,ArrayList), Exception Handling. - Tools: Any Java IDE (e.g., IntelliJ IDEA, Eclipse) or a text editor with
javacandjavacommands.
The project is divided into the following classes:
-
Passenger:
- Stores details about passengers (name, phone number, seat number).
- Overrides
toString()to display passenger details.
-
Bus:
- Represents a bus with an ID, capacity, and seat reservations.
- Contains methods for booking, canceling, and displaying seats.
-
BusReservationSystem:
- The main class that interacts with users via a menu-driven interface.
- Manages multiple buses and provides options to book, cancel, and view reservations.
-
Clone this repository:
git clone https://github.com/your-username/bus-reservation-system.git cd bus-reservation-system -
Compile the code:
javac BusReservationSystem.java
-
Run the program:
java BusReservationSystem
-
View all buses:
==== Bus Reservation System ==== 1. View All Buses Bus ID: Bus101, Capacity: 10 Bus ID: Bus102, Capacity: 15 -
Book a seat:
Enter Bus ID: Bus101 Enter Seat Number to Book: 3 Enter Passenger Name: John Doe Enter Phone Number: 1234567890 Seat 3 successfully booked for John Doe. -
View available seats:
Enter Bus ID: Bus101 Available seats: 1, 2, 4, 5... -
Cancel a seat:
Enter Bus ID: Bus101 Enter Seat Number to Cancel: 3 Seat 3 successfully canceled.
- Persistent Storage: Add File I/O to save reservations and retrieve them after restarting the program.
- Graphical Interface: Implement a GUI using JavaFX or Swing.
- Database Integration: Use JDBC to connect to a database for managing buses and reservations.
- Web Application: Develop a web-based system using Java Spring Boot.
This project is licensed under the MIT License. Feel free to use, modify, and distribute it.
Contributions are welcome! Please open an issue or submit a pull request with your improvements or suggestions.
For any questions or feedback, please reach out to [birijithroshan29@gmail.com].
Happy Coding!