Pankaj-Str / Complete-Python-Mastery

Explore the world of Python programming with 'Complete Python Mastery'! Our repository, led by Pankaj, offers a series of in-depth tutorials under the banner 'Codes with Pankaj.' Dive into hands-on coding examples, insightful explanations, and practical projects as Pankaj guides you through mastering Python.
https://www.codeswithpankaj.com/
32 stars 25 forks source link

Movie Ticket Management System #9

Open Pankaj-Str opened 2 months ago

Pankaj-Str commented 2 months ago

Python Programming Assignment: Movie Ticket Management System

Objective: Develop a command-line Movie Ticket Management System using Python. This project will help you practice object-oriented programming, data structures, file handling, and basic algorithms.

Requirements:

  1. Movie Class: Create a class called 'Movie' with the following attributes:

    • title (string)
    • duration (integer, in minutes)
    • rating (string, e.g., "PG", "PG-13", "R")
    • show_times (list of datetime objects)

    Methods:

    • init: Initialize the movie object
    • str: Return a string representation of the movie
    • add_show_time: Add a new show time for the movie
    • remove_show_time: Remove a show time for the movie
  2. Theater Class: Create a class called 'Theater' with the following attributes:

    • name (string)
    • capacity (integer)
    • movies (list of Movie objects)
    • seats (dictionary mapping show times to lists of available seats)

    Methods:

    • init: Initialize the theater object
    • add_movie: Add a new movie to the theater
    • remove_movie: Remove a movie from the theater
    • display_movies: Show all movies currently playing
    • display_show_times: Show all show times for a specific movie
    • book_ticket: Book a ticket for a specific movie and show time
    • cancel_booking: Cancel a booking for a specific movie and show time
  3. TicketSystem Class: Create a class called 'TicketSystem' to manage the overall system:

    • theaters (list of Theater objects)

    Methods:

    • init: Initialize the ticket system
    • add_theater: Add a new theater to the system
    • remove_theater: Remove a theater from the system
    • display_theaters: Show all theaters in the system
    • save_to_file: Save the system data to a file
    • load_from_file: Load the system data from a file
  4. Main Program: Create a main program that does the following:

    • Initializes a TicketSystem object
    • Loads existing data from a file (if available)
    • Presents a menu to the user with the following options: a. Add a new theater b. Add a new movie to a theater c. Display all theaters d. Display movies in a specific theater e. Book a ticket f. Cancel a booking g. Save and exit
    • Implements each menu option using the TicketSystem and Theater class methods
    • Saves the system data to a file before exiting
  5. Error Handling: Implement proper error handling throughout the program. For example:

    • Handle file not found errors when loading data
    • Handle invalid input from users
    • Prevent overbooking of seats
    • Handle cases where a movie or theater doesn't exist
  6. Data Persistence: Use file I/O to save and load the system data. You can use JSON or pickle for data storage.

Example Usage:

Welcome to the Movie Ticket Management System

  1. Add a new theater
  2. Add a new movie to a theater
  3. Display all theaters
  4. Display movies in a specific theater
  5. Book a ticket
  6. Cancel a booking
  7. Save and exit Enter your choice: 1

Enter theater name: Cineplex Enter theater capacity: 100

Theater added successfully!

  1. Add a new theater
  2. Add a new movie to a theater
  3. Display all theaters
  4. Display movies in a specific theater
  5. Book a ticket
  6. Cancel a booking
  7. Save and exit Enter your choice: 2

Enter theater name: Cineplex Enter movie title: Inception Enter movie duration (in minutes): 148 Enter movie rating: PG-13 Enter show time (YYYY-MM-DD HH:MM): 2024-09-01 19:30

Movie added successfully!

  1. Add a new theater
  2. Add a new movie to a theater
  3. Display all theaters
  4. Display movies in a specific theater
  5. Book a ticket
  6. Cancel a booking
  7. Save and exit Enter your choice: 5

Enter theater name: Cineplex Enter movie title: Inception Enter show time (YYYY-MM-DD HH:MM): 2024-09-01 19:30 Enter number of tickets: 2

Tickets booked successfully!

  1. Add a new theater
  2. Add a new movie to a theater
  3. Display all theaters
  4. Display movies in a specific theater
  5. Book a ticket
  6. Cancel a booking
  7. Save and exit Enter your choice: 7

System data saved. Goodbye!

Bonus Challenges (Optional):

  1. Implement a user authentication system with different privileges for admins and customers.
  2. Add a feature to generate reports (e.g., most popular movies, theater occupancy rates).
  3. Implement a simple recommendation system based on user booking history.
  4. Create a basic GUI using a library like Tkinter or PyQt.

Submission Instructions:

  1. Submit your Python script(s) with clear comments explaining your code.
  2. Include a brief README file explaining how to run your program and any dependencies required.
  3. If you've implemented any bonus challenges, describe them in your README.

Evaluation Criteria: