- Read the guideline before start
You have opened your own cinema. To have a better idea of what's going on in the cinema you decided to keep a record of events in the cinema. For this purpose you have to create such modules:
-
In directory
app
create packagecinema
. In this package create modules:bar.py
- inside this module createCinemaBar
class that describes work of cinema bar. This class should have only one static methodsell_product
, that takesproduct
- name of the product that customer wants andcustomer
-Customer
instance, that means customer. Thesell_product
method sells a product to the customer and displays which product was sold and to whom.
cb = CinemaBar() customer = Customer("Bob", "popcorn") cb.sell_product(customer=customer, product=customer.food) # Cinema bar sold popcorn to Bob.
hall.py
- inside this module createCinemaHall
class that describes actions during the movie session. Its__init__
method takes and stores ONLY thenumber
of the hall in the cinema. This class should have only one methodmovie_session
, that takesmovie_name
,customers
- list of a customers (Customer
instances),cleaning_staff
- cleaner (Cleaner
instance). This method prints about movie start, calls customers methodwatch_movie
, prints about movie end, calls cleaner methodclean_hall
. So, we are expecting that everything listed above will be performed inmovie_session
function.
-
In directory
app
create packagepeople
. In this package create modules:customer.py
- inside this module createCustomer
class, its__init__
method takes and storesname
,food
- food that customer wants to buy in cinema bar. This class should have only one methodwatch_movie
, this method takesmovie
and prints what movie customer is watching.
bob = Customer(name="Bob", food="popcorn") bob.watch_movie(movie="Madagascar") # Bob is watching "Madagascar".
cinema_staff.py
- inside this module createCleaner
class, its__init__
method takes and storesname
. This class should have only one methodclean_hall
, this method takeshall_number
- number of hall that cleaner have to clean and prints that cleaner is cleaning that hall.
anna = Cleaner(name="Anna") anna.clean_hall(hall_number=5) # Cleaner Anna is cleaning hall number 5.
In the module main.py
you have to import all this classes. Classes
should be imported by absolute path, that starts with 'app.' with
keyword 'from'. Write a
function cinema_visit
that takes movie
, customers
- a list
of customers, elements are dicts with 'name' and desired 'food' of a
customer, hall_number
- number of the hall in cinema,
cleaner
- name of the cleaner, that will clean the
hall after movie session.
This function should create instances of Customer
, CinemaHall
, and Cleaner
.
First, the cinema bar should sell food to customers. To do this, you can use the CinemaBar
class without creating an instance. Then, the cinema hall should schedule a movie session,
and finally, a cleaner should clean the cinema hall. We expect each class to work with the provided data,
accepting parameters in the correct order and having the necessary methods.
No additional checks or error handling are needed!
Example (do not add it to main.py
):
customers = [
{"name": "Bob", "food": "Coca-cola"},
{"name": "Alex", "food": "popcorn"}
]
hall_number = 5
cleaner_name = "Anna"
movie = "Madagascar"
cinema_visit(customers=customers, hall_number=hall_number, cleaner=cleaner_name, movie=movie)
# Cinema bar sold Coca-cola to Bob.
# Cinema bar sold popcorn to Alex.
# "Madagascar" started in hall number 5.
# Bob is watching "Madagascar".
# Alex is watching "Madagascar".
# "Madagascar" ended.
# Cleaner Anna is cleaning hall number 5.
Important Note: Each method responsible for performing a task should only print a message using
the print()
function. There is no need to return anything or use the logging
module.
Finally, check your code using this checklist before pushing your solution.