American Young Coder

AYC logo
Loading Events

« All Events

  • This event has passed.

6 PM – Python OOP – Joel

January 22 @ 6:00 pm - 7:00 pm

Today we did:
  1. We worked on GameSystem and finished it.
Homework:
  • Cinema Ticket Booking System:
  • You need to create 3 Python classes in three separate files:

    a. cinema.py – Cinema class
    b. imax_cinema.py – IMAXCinema class
    c. cinema_system.py – CinemaSystem

  • Cinema class will have the following attributes:

    a. name – String
    b. base_price – Integer
    c. type – String
    Default value “Regular Cinema”

  • get_info(self):This method will return a string combination of attributes name, base_price, and type in the following format:

    <name> – $<base_price> – <type>

    Example:

    CGV – $10 – Regular Cinema

  • get_ticket_price(self, tickets):

    tickets – Integer

    This method will calculate the total ticket price using the formula:

    tickets * base_price

    This method will return the total ticket price.

  • IMAXCinema class

    a. This class needs to inherit from Cinema class

    b. This class needs to have attribute:

    self.type = “IMAX Cinema”

    c. This class needs to override the method:

    get_ticket_price(self, tickets)

    Inside this method, ticket price will be calculated using:

    tickets * base_price * 1.5

    This method must also print:

    “IMAX experience includes premium screen and sound!”

  • CinemaSystem class is where the program starts.
  • CinemaSystem class will have a dictionary to store all cinemas

    Dictionary key → cinema name

    Dictionary value → either Cinema or IMAXCinema object

  • CinemaSystem will provide the following 3 functionalities

    – Add cinema

    – Buy tickets

    – Exit

  • CinemaSystem will provide 2 options when adding a cinema

    – Regular Cinema

    – IMAX Cinema

    Regular Cinema → represented by Cinema class

    IMAX Cinema → represented by IMAXCinema class

  • Buy Tickets Functionality

    When user selects Buy tickets, the system will:

    – Display all cinemas in the system

    – Ask user to select a cinema by name

    – Ask user to input number of tickets

    – Calculate total ticket price using: get_ticket_price(tickets)

    – Display total price

Details

Date:
January 22
Time:
6:00 pm - 7:00 pm