- 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. This method prints what product and to whom cinema sold.
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 storesnumber
- number of the hall in 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
.
-
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
- 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 make Customers
instances, instance of CinemaHall
and CinemaBar
, instance of Cleaner
. First, cinema bar should sell food to
customers, then cinema hall should make a movie session and finally cleaner
cleans cinema hall.
Example:
customers = [
{"name": "Bob", "food": "Coca-cola"},
{"name": "Alex", "food": "popcorn"}
]
hall_number = 5
cleaner_name = "Anna"
movie = "Madagascar"
cinema_visit(customers=customers, hall_number=5, cleaner="Anna", movie="Madagascar")
# 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.