In today’s digital age, movie ticket booking systems have become an essential part of the entertainment industry. The Movie Ticket Booking System presented here is a simplified text-based application created using Python. It allows users to view available seats, purchase movie tickets, and access booking statistics. This case study showcases a straightforward implementation of a movie ticket booking system.
class MovieTicketBookingSystem: def __init__(self, rows, seats_per_row): self.rows = rows self.seats_per_row = seats_per_row self.seating = [[False] * seats_per_row for _ in range(rows)] self.total_seats = rows * seats_per_row self.current_income = 0 self.total_income = 0 self.calculate_total_income() def calculate_total_income(self): if self.total_seats ") def buy_ticket(self, row, seat): if self.seating[row - 1][seat - 1]: print("This seat is already booked. Please select another seat.") return False ticket_price = 10 if self.total_seats ") if input("Do you want to book this ticket? (yes/no): ").lower() == "yes": self.seating[row - 1][seat - 1] = True self.current_income += ticket_price return True return False def get_statistics(self): percentage_booked = (sum(row.count(True) for row in self.seating) / self.total_seats) * 100 return f"Number of purchased tickets:\n" \ f"Percentage: %\n" \ f"Current income: $\n" \ f"Total income: $" def main(): rows = int(input("Enter the number of rows: ")) seats_per_row = int(input("Enter the number of seats in each row: ")) booking_system = MovieTicketBookingSystem(rows, seats_per_row) while True: print("\n1. Show the seats") print("2. Buy a ticket") print("3. Statistics") print("0. Exit") choice = int(input("Enter your choice: ")) if choice == 1: booking_system.display_seating() elif choice == 2: row = int(input("Enter the row number: ")) seat = int(input("Enter the seat number: ")) if 1 Output:
Implementation:
The Movie Ticket Booking System includes the following components:
- MovieTicketBookingSystem Class: This class initializes the system with the specified number of rows and seats per row, manages the seating arrangement, and calculates income.
- Display Seating: The system displays the current seating arrangement, indicating available seats with ‘S’ and booked seats with ‘E’.
- Buy Ticket: Users can select a seat by specifying the row and seat number. The system checks seat availability, calculates the ticket price, and allows users to book or cancel a seat.
- Statistics: Users can access booking statistics, including the number of purchased tickets, the percentage of booked seats, and the current and total income.
- Main Function: The main function takes user inputs to perform actions like displaying seats, buying tickets, accessing statistics, or exiting the system.
Case Study Steps:
- Launch the Movie Ticket Booking System.
- Input the number of rows and seats per row, configuring the theater.
- Select options from the menu to view available seats, purchase tickets, or check booking statistics.
- To view available seats, select option ‘1’. The system displays the current seating arrangement.
- To buy a ticket, select option ‘2’. Specify the row and seat number, and the system will calculate the ticket price. Confirm the purchase or cancel.
- To view booking statistics, select option ‘3’. The system displays the number of purchased tickets, the percentage of booked seats, and the current and total income.
- To exit the system, select option ‘0’.
Conclusion:
The Movie Ticket Booking System presented in this case study demonstrates the fundamental concepts of creating a movie ticket booking application using Python. Although this is a basic text-based implementation, it highlights the essential components of a real-world movie ticket booking system, such as seat availability, pricing, and booking statistics. Further development could include a graphical user interface (GUI) and database integration for a more user-friendly and robust system.
![]()