From 486f96c44e8d435c80c64b726161e70fe2ab14b6 Mon Sep 17 00:00:00 2001 From: Maria Date: Thu, 6 Mar 2025 20:43:04 +0200 Subject: [PATCH 1/5] E --- app/cinema/__init__.py | 0 app/cinema/bar.py | 7 +++++++ app/cinema/hall.py | 13 +++++++++++++ app/main.py | 14 +++++++++++--- app/people/__init__.py | 0 app/people/cinema_staff.py | 6 ++++++ app/people/customer.py | 7 +++++++ 7 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 app/cinema/__init__.py create mode 100644 app/cinema/bar.py create mode 100644 app/cinema/hall.py create mode 100644 app/people/__init__.py create mode 100644 app/people/cinema_staff.py create mode 100644 app/people/customer.py diff --git a/app/cinema/__init__.py b/app/cinema/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/app/cinema/bar.py b/app/cinema/bar.py new file mode 100644 index 000000000..ac347a647 --- /dev/null +++ b/app/cinema/bar.py @@ -0,0 +1,7 @@ +from app.people.customer import Customer + + +class CinemaBar: + + def sell_product(self, product: str, customer: Customer): + print(f"Cinema bar sold {product} to {customer.name}") diff --git a/app/cinema/hall.py b/app/cinema/hall.py new file mode 100644 index 000000000..86ed47f86 --- /dev/null +++ b/app/cinema/hall.py @@ -0,0 +1,13 @@ +from app.people.customer import Customer +from app.people.cinema_staff import Cleaner + + +class CinemaHall: + def __init__(self, number: int): + self.number = number + + def movie_session(self, movie_name: str, customers: Customer, cleaning_staff: Cleaner): + print(f"{movie_name} started in hall number {self.number}.") + Customer.watch_movie() + print(f"{movie_name} ended.") + Cleaner.clean_hall(self.number) diff --git a/app/main.py b/app/main.py index 7eeef6542..c75611af8 100644 --- a/app/main.py +++ b/app/main.py @@ -1,6 +1,14 @@ -# write your imports here +from app.cinema.bar import CinemaBar +from app.cinema.hall import CinemaHall +from app.people.customer import Customer +from app.people.cinema_staff import Cleaner def cinema_visit(customers: list, hall_number: int, cleaner: str, movie: str): - # write you code here - pass + result_list = [] + for element in customers: + result_list.append(Customer(element["name"], element["food"])) + for customer in result_list: + CinemaBar.sell_product(customer.food, customer) + for element in result_list: + CinemaHall.movie_session(movie, element.name, cleaner) diff --git a/app/people/__init__.py b/app/people/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/app/people/cinema_staff.py b/app/people/cinema_staff.py new file mode 100644 index 000000000..1ccfd8710 --- /dev/null +++ b/app/people/cinema_staff.py @@ -0,0 +1,6 @@ +class Cleaner: + def __init__(self, name: str): + self.name = name + + def clean_hall(self, hall_number: int): + print(f"Cleaner {self.name} is cleaning hall number {hall_number}.") diff --git a/app/people/customer.py b/app/people/customer.py new file mode 100644 index 000000000..e910d0ada --- /dev/null +++ b/app/people/customer.py @@ -0,0 +1,7 @@ +class Customer: + def __init__(self, name: str, food: str): + self.name = name + self.food = food + + def watch_movie(self, movie: str): + print(f"{self.name} is watching {movie}") From d1c2820cd34ca52efccc93f961e635cf90b7a48e Mon Sep 17 00:00:00 2001 From: Maria Date: Thu, 6 Mar 2025 21:23:44 +0200 Subject: [PATCH 2/5] Solution --- .flake8 | 2 +- app/cinema/bar.py | 2 +- app/cinema/hall.py | 4 ++-- app/main.py | 3 +-- app/people/cinema_staff.py | 4 ++-- app/people/customer.py | 4 ++-- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.flake8 b/.flake8 index d7459204e..3f5e06ff6 100644 --- a/.flake8 +++ b/.flake8 @@ -4,4 +4,4 @@ ignore = E203, E266, W503, ANN002, ANN003, ANN101, ANN102, ANN401, N807, N818 max-line-length = 79 max-complexity = 18 select = B,C,E,F,W,T4,B9,ANN,Q0,N8,VNE -exclude = venv, tests +exclude = venv, tests, .venv diff --git a/app/cinema/bar.py b/app/cinema/bar.py index ac347a647..d1197f8be 100644 --- a/app/cinema/bar.py +++ b/app/cinema/bar.py @@ -3,5 +3,5 @@ class CinemaBar: - def sell_product(self, product: str, customer: Customer): + def sell_product(self, product: str, customer: Customer) -> None: print(f"Cinema bar sold {product} to {customer.name}") diff --git a/app/cinema/hall.py b/app/cinema/hall.py index 86ed47f86..dcdb1b835 100644 --- a/app/cinema/hall.py +++ b/app/cinema/hall.py @@ -3,10 +3,10 @@ class CinemaHall: - def __init__(self, number: int): + def __init__(self, number: int) -> None: self.number = number - def movie_session(self, movie_name: str, customers: Customer, cleaning_staff: Cleaner): + def movie_session(self, movie_name: str) -> None: print(f"{movie_name} started in hall number {self.number}.") Customer.watch_movie() print(f"{movie_name} ended.") diff --git a/app/main.py b/app/main.py index c75611af8..15ca8dcb2 100644 --- a/app/main.py +++ b/app/main.py @@ -1,10 +1,9 @@ from app.cinema.bar import CinemaBar from app.cinema.hall import CinemaHall from app.people.customer import Customer -from app.people.cinema_staff import Cleaner -def cinema_visit(customers: list, hall_number: int, cleaner: str, movie: str): +def cinema_visit(customers: list, cleaner: str, movie: str) -> None: result_list = [] for element in customers: result_list.append(Customer(element["name"], element["food"])) diff --git a/app/people/cinema_staff.py b/app/people/cinema_staff.py index 1ccfd8710..3724afa97 100644 --- a/app/people/cinema_staff.py +++ b/app/people/cinema_staff.py @@ -1,6 +1,6 @@ class Cleaner: - def __init__(self, name: str): + def __init__(self, name: str) -> None: self.name = name - def clean_hall(self, hall_number: int): + def clean_hall(self, hall_number: int) -> None: print(f"Cleaner {self.name} is cleaning hall number {hall_number}.") diff --git a/app/people/customer.py b/app/people/customer.py index e910d0ada..5ae6ec27f 100644 --- a/app/people/customer.py +++ b/app/people/customer.py @@ -1,7 +1,7 @@ class Customer: - def __init__(self, name: str, food: str): + def __init__(self, name: str, food: str) -> None: self.name = name self.food = food - def watch_movie(self, movie: str): + def watch_movie(self, movie: str) -> None: print(f"{self.name} is watching {movie}") From 8981da2c7371385e5d33a567f212da0084032ce0 Mon Sep 17 00:00:00 2001 From: Maria Date: Fri, 7 Mar 2025 19:27:23 +0200 Subject: [PATCH 3/5] Solution --- app/cinema/bar.py | 2 +- app/cinema/hall.py | 11 ++++++----- app/main.py | 11 +++++++---- app/people/customer.py | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/cinema/bar.py b/app/cinema/bar.py index d1197f8be..09214f698 100644 --- a/app/cinema/bar.py +++ b/app/cinema/bar.py @@ -4,4 +4,4 @@ class CinemaBar: def sell_product(self, product: str, customer: Customer) -> None: - print(f"Cinema bar sold {product} to {customer.name}") + print(f"Cinema bar sold {product} to {customer.name}.") diff --git a/app/cinema/hall.py b/app/cinema/hall.py index dcdb1b835..a83db54a9 100644 --- a/app/cinema/hall.py +++ b/app/cinema/hall.py @@ -6,8 +6,9 @@ class CinemaHall: def __init__(self, number: int) -> None: self.number = number - def movie_session(self, movie_name: str) -> None: - print(f"{movie_name} started in hall number {self.number}.") - Customer.watch_movie() - print(f"{movie_name} ended.") - Cleaner.clean_hall(self.number) + def movie_session(self, movie_name: str, customers: list[Customer], cleaner: Cleaner) -> None: + print(f"\"{movie_name}\" started in hall number {self.number}.") + for customer in customers: + customer.watch_movie(movie_name) + print(f"\"{movie_name}\" ended.") + cleaner.clean_hall(self.number) diff --git a/app/main.py b/app/main.py index 15ca8dcb2..00d10e8cf 100644 --- a/app/main.py +++ b/app/main.py @@ -1,13 +1,16 @@ from app.cinema.bar import CinemaBar from app.cinema.hall import CinemaHall from app.people.customer import Customer +from app.people.cinema_staff import Cleaner -def cinema_visit(customers: list, cleaner: str, movie: str) -> None: +def cinema_visit(customers: list, hall_number: int, cleaner: str, movie: str) -> None: result_list = [] for element in customers: result_list.append(Customer(element["name"], element["food"])) + cinema_bar = CinemaBar() for customer in result_list: - CinemaBar.sell_product(customer.food, customer) - for element in result_list: - CinemaHall.movie_session(movie, element.name, cleaner) + cinema_bar.sell_product(customer.food, customer) + hall = CinemaHall(hall_number) + cl = Cleaner(cleaner) + hall.movie_session(movie, result_list, cl) diff --git a/app/people/customer.py b/app/people/customer.py index 5ae6ec27f..63b688de5 100644 --- a/app/people/customer.py +++ b/app/people/customer.py @@ -4,4 +4,4 @@ def __init__(self, name: str, food: str) -> None: self.food = food def watch_movie(self, movie: str) -> None: - print(f"{self.name} is watching {movie}") + print(f"{self.name} is watching \"{movie}\".") From ea6bd2201c2bdba3b592ae2438fb80cd6f7a1de8 Mon Sep 17 00:00:00 2001 From: Maria Date: Fri, 7 Mar 2025 19:46:09 +0200 Subject: [PATCH 4/5] Solution --- app/cinema/hall.py | 4 +++- app/main.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/cinema/hall.py b/app/cinema/hall.py index a83db54a9..e98513097 100644 --- a/app/cinema/hall.py +++ b/app/cinema/hall.py @@ -6,7 +6,9 @@ class CinemaHall: def __init__(self, number: int) -> None: self.number = number - def movie_session(self, movie_name: str, customers: list[Customer], cleaner: Cleaner) -> None: + def movie_session( + self, movie_name: str, customers: list[Customer], cleaner: Cleaner + ) -> None: print(f"\"{movie_name}\" started in hall number {self.number}.") for customer in customers: customer.watch_movie(movie_name) diff --git a/app/main.py b/app/main.py index 00d10e8cf..d971c55fa 100644 --- a/app/main.py +++ b/app/main.py @@ -4,7 +4,9 @@ from app.people.cinema_staff import Cleaner -def cinema_visit(customers: list, hall_number: int, cleaner: str, movie: str) -> None: +def cinema_visit( + customers: list, hall_number: int, cleaner: str, movie: str +) -> None: result_list = [] for element in customers: result_list.append(Customer(element["name"], element["food"])) From b292ca893f81b05578f164498c9ca6660f739d68 Mon Sep 17 00:00:00 2001 From: Maria Date: Fri, 7 Mar 2025 19:51:48 +0200 Subject: [PATCH 5/5] Solution --- app/cinema/hall.py | 4 ++-- app/people/customer.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/cinema/hall.py b/app/cinema/hall.py index e98513097..4d941d5f7 100644 --- a/app/cinema/hall.py +++ b/app/cinema/hall.py @@ -9,8 +9,8 @@ def __init__(self, number: int) -> None: def movie_session( self, movie_name: str, customers: list[Customer], cleaner: Cleaner ) -> None: - print(f"\"{movie_name}\" started in hall number {self.number}.") + print(f'\"{movie_name}\" started in hall number {self.number}.') for customer in customers: customer.watch_movie(movie_name) - print(f"\"{movie_name}\" ended.") + print(f'\"{movie_name}\" ended.') cleaner.clean_hall(self.number) diff --git a/app/people/customer.py b/app/people/customer.py index 63b688de5..cac7d7d0a 100644 --- a/app/people/customer.py +++ b/app/people/customer.py @@ -4,4 +4,4 @@ def __init__(self, name: str, food: str) -> None: self.food = food def watch_movie(self, movie: str) -> None: - print(f"{self.name} is watching \"{movie}\".") + print(f'{self.name} is watching \"{movie}\".')