All Projects

Bus Ticket Booking System in Python
Bus Ticket Booking System in Java
Bus Ticket Booking System in Cpp
Bus Ticket Booking System in C
Cafe Order System in Python
Cafe Order System in Java
Cafe Order System in Cpp
Cafe Order System in C
Social Media Account Details Manager in Python
Social Media Account Details Manager in Java
Social Media Account Details Manager in Cpp
Social Media Account Details Manager in C
Mini ATM in Python Language
Mini ATM in Java Language
Mini ATM in cpp language
Mini ATM in c language
Pocket Money Manager in Python Language
Pocket Money Manager in Java Language
Pocket Money Manager in Cpp Language
Pocket Money Manager in C Language
Username Password Generator in Python Language
Username Password Generator in Cpp Language
Username Password Generator in C Language
Telephone Directory in Python Language
Telephone Directory in Java Language
Telephone Directory in Cpp Language
Telephone Directory in C Language
Calander in Cpp Language
Calander in C Language
NoteBook in Python Language
NoteBook in Cpp Language
NoteBook in C Language
Voting System in Python Language
Voting System in Java Language
Voting System in Cpp Language
Voting System in C Language
Age Calculator in Python Language
Age Calculator in Java Language
Age Calculator in Cpp Language
Age Calculator in C Language
Currency Converter in Python Language
Currency Converter in Java Language
Currency Converter in Cpp Language
Currency Converter in C Language
Random Password Generator in python language
Random Password Generator in java language
Random Password Generator in cpp language
Random Password Generator in c language
Billing System in python language
Billing System in c++ language
Billing System in c language
Atm in c language

Bus Ticket Booking System in Python


Aniket The Programmer

1K+ Subscribers

Click To Subscribe My Channel

Subscribe

Source Code

        
class Booking:
    def __init__(self, name, seat_no, source, destination):
        self.name = name
        self.seat_no = seat_no
        self.source = source
        self.destination = destination
        # Add more fields as needed

class BusBookingSystem:
    def __init__(self):
        self.bookings = []

    def book_seat(self):
        name = input("Enter name: ")
        seat_no = int(input("Enter seat number: "))
        source = input("Enter Source: ")
        destination = input("Enter Destination: ")
        # Add more input fields as needed

        new_booking = Booking(name, seat_no, source, destination)
        self.bookings.append(new_booking)
        print("Seat booked successfully.")

    def view_reservations(self):
        if not self.bookings:
            print("No reservations made yet.")
            return

        print("All reservations:")
        print("Seat No.\tName\t\tSource\t\tDestination")
        
        for booking in self.bookings:
            print("--------------------------------------------------------------")
            print(f"{booking.seat_no}\t\t{booking.name}\t\t{booking.source}\t\t{booking.destination}")

    def edit_reservation(self):
        seat_to_edit = int(input("Enter seat number to edit: "))

        found = False
        for booking in self.bookings:
            if booking.seat_no == seat_to_edit:
                booking.name = input("Enter new name: ")
                booking.source = input("Enter new source: ")
                booking.destination = input("Enter new destination: ")
                # Add more fields to edit as needed

                print("Reservation edited successfully.")
                found = True
                break

        if not found:
            print("Reservation not found.")

    def print_ticket(self):
        seat_to_print = int(input("Enter seat number to print ticket: "))

        found = False
        for booking in self.bookings:
            if booking.seat_no == seat_to_print:
                print(f"Ticket for Seat No. {booking.seat_no}")
                print(f"Passenger Name: {booking.name}")
                print(f"Passenger Source: {booking.source}")
                print(f"Passenger Destination: {booking.destination}")
                # Add more fields to print as needed

                found = True
                break

        if not found:
            print("Reservation not found.")

def main():
    system = BusBookingSystem()
    choice = 0

    while choice != 5:
        print("\nMini Bus Booking System")
        print("1. Book a seat")
        print("2. View reservations")
        print("3. Edit a reservation")
        print("4. Print a ticket")
        print("5. Exit")
        choice = int(input("Enter your choice: "))

        if choice == 1:
            system.book_seat()
        elif choice == 2:
            system.view_reservations()
        elif choice == 3:
            system.edit_reservation()
        elif choice == 4:
            system.print_ticket()
        elif choice == 5:
            print("Exiting...")
        else:
            print("Invalid choice. Please enter a valid option.")

if __name__ == "__main__":
    main()
        
    

Source Code Github Link: View

View Video On Youtube Link: View