A console-based bus booking application written in C++. It allows users to book and manage bus seats, display bus details, search routes, and more—all through a simple, menu-driven interface.
- Overview
- Key Features
- System Design & Principles
- Core Components
- Installation
- Usage
- Contributing
- License
- Contact
- User Flow Diagram
The Bus Booking System provides these core functionalities:
-
Install (Add) a New Bus
- Enter bus details (bus number, driver, times, origin, destination).
- Cancel at any prompt by typing
0
or leaving it empty.
-
Reserve a Seat
- Select a bus by its bus number, pick a seat (1–32), and book it under a passenger name.
-
Show Bus Details
- Displays comprehensive info for a bus, including a seat map, fare, and seat occupancy.
-
Show All Buses
- Lists all installed buses, showing concise details.
-
Cancel a Seat
- Frees up a previously reserved seat on a bus.
-
Search Buses by Route
- Finds buses matching a given
origin
→destination
.
- Finds buses matching a given
-
Exit
- Ends the program gracefully.
- 32-Seat Layout: Each bus has 8 rows × 4 columns = 32 seats total.
- Default Seat Fare: Each seat includes a
fare
field (initially 300.0, adjustable in code). - User-Focused: Cancels any operation if
0
or empty input is entered. - In-Memory Storage: Data is reset when the program terminates (no persistence).
- Modularity: Each Bus is encapsulated in a
Bus
class, which manages seat info and bus data. A globalstd::vector<Bus>
(busList
) holds all bus objects. - Loose Coupling: Functions like
searchBusesByRoute()
operate on the global bus list and only rely on each bus’s public interface. - Simplicity: Menu-driven design with minimal dependencies. Users can quickly navigate through numeric choices.
- C++ Standard Library: Utilizes
<vector>
,<algorithm>
, and standard I/O for ease of maintenance and clarity. - Error Handling / Cancellation: If the user enters
"0"
or empty input at critical prompts, the operation is cancelled to prevent partial data.
-
Bus
Class- Holds bus details: number, driver, times, route (
from
,to
). - Maintains a 2D vector of
Seat
, each seat havingpassengerName
andfare
. - Functions for installation, allotment (reservation), cancellation, and displaying the bus.
- Holds bus details: number, driver, times, route (
-
Global Functions
showAllBuses()
: Lists all buses.searchBusesByRoute()
: Filters buses by matching route.printLine()
,clearScreen()
: Utilities for UI.
-
main()
Menu Logic- Presents a loop with numeric choices.
- Interacts with the
Bus
class or global functions to fulfill user requests.
- C++ Compiler: Ensure you have a C++11 compatible compiler installed (e.g.,
g++
,clang++
).
-
Clone the Repository
git clone https://github.com/yourusername/bus-booking-system.git cd bus-booking-system
-
Compile the Code
g++ -std=c++11 -o BusBookingSystem main.cpp
-
Run the Application
./BusBookingSystem
Upon running the application, you will be presented with a menu:
-
Install New Bus
- Input bus details as prompted.
- Enter
0
or leave empty at any prompt to cancel.
-
Reserve a Seat
- Select a bus by its number.
- Choose a seat number (1-32).
- Enter passenger's name to reserve.
-
Show Bus Details
- Input the bus number to view detailed information and seat map.
-
Show All Buses Available
- Displays a list of all installed buses with basic details.
-
Cancel (Remove) a Seat
- Select a bus and seat number to cancel the reservation.
-
Search Buses by Route
- Enter origin and destination to find matching buses.
-
Exit
- Terminates the application.
Contributions are welcome! Please follow these steps:
- Fork the Repository
- Create a Feature Branch
git checkout -b feature/YourFeature
- Commit Your Changes
git commit -m "Add Your Feature"
- Push to the Branch
git push origin feature/YourFeature
- Open a Pull Request
Please ensure your code follows the project's coding standards and includes appropriate documentation.
This project is licensed under the MIT License.
For any inquiries or feedback, please contact:
- Name: Rajeev Ranjan
- Email: [email protected]
- GitHub: RajeevRanjan27
Below is a simplified diagram showing how a user navigates the system: