-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution #1749
base: master
Are you sure you want to change the base?
Solution #1749
Changes from 6 commits
e4b085a
dfe3254
e85f2cb
0f90598
35fc9ed
09b76e7
c2e70fb
fdb979c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class CinemaBar: | ||
|
||
@staticmethod | ||
def sell_product(customer: "Customer", product: str) -> None: | ||
print(f"Cinema bar sold {product} to {customer}.") | ||
|
||
|
||
class Customer: | ||
|
||
def __init__(self, name: str, food: str) -> None: | ||
self.name = name | ||
self.food = food | ||
|
||
def __str__(self) -> str: | ||
return self.name | ||
|
||
def watch_movie(self) -> None: | ||
print(f"Customer {self.name} is watching a movie") | ||
|
||
|
||
cb = CinemaBar() | ||
customer = Customer("Bob", "popcorn") | ||
cb.sell_product(customer=customer, product=customer.food) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from app.cinema.bar import Customer | ||
|
||
|
||
class CinemaHall: | ||
|
||
def __init__(self, number: int) -> None: | ||
self.number: int = number | ||
|
||
def movie_session(self, | ||
movie_name: str, | ||
customers: list["Customer"], | ||
cleaning_staff: "Cleaner" | ||
) -> None: | ||
print(f'"{movie_name}" started in hall number {self.number}.') | ||
for customer in customers: | ||
customer.watch_movie(movie_name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Comment on lines
+16
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
print(f'"{movie_name}" ended.') | ||
cleaning_staff.clean_hall(self.number) | ||
|
||
|
||
class Cleaner: | ||
|
||
def __init__(self, name: str) -> None: | ||
self.name = name | ||
|
||
def clean_hall(self, number_hall: object) -> None: | ||
print(f"Cleaner {self.name} is cleaning hall {number_hall}.") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,37 @@ | ||
# write your imports here | ||
from app.cinema.bar import CinemaBar | ||
from app.cinema.hall import CinemaHall | ||
from app.people.cinema_staff import Cleaner | ||
from app.people.customer import Customer | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The import path |
||
from typing import List, Dict | ||
|
||
|
||
def cinema_visit(customers: list, hall_number: int, cleaner: str, movie: str): | ||
# write you code here | ||
pass | ||
def cinema_visit(customers: List[Dict[str, str]], | ||
hall_number: int, | ||
cleaner: str, | ||
movie: str) -> None : | ||
customer_objects = [Customer(name=c["name"], food=c["food"]) | ||
for c in customers] | ||
|
||
for customer in customer_objects: | ||
CinemaBar.sell_product(product=customer.food, customer=customer) | ||
|
||
cinema_hall = CinemaHall(hall_number) | ||
|
||
cleaning_staff = Cleaner(name=cleaner) | ||
|
||
cinema_hall.movie_session(movie_name=movie, customers=customer_objects, | ||
cleaning_staff=cleaning_staff) | ||
|
||
|
||
if __name__ == "__main__": | ||
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) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Cleaner: | ||
|
||
def __init__(self, name: str) -> None: | ||
self.name = name | ||
|
||
def clean_hall(self, hall_number: int) -> None: | ||
print(f"Cleaner {self.name} is cleaning hall number {hall_number}.") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Customer: | ||
|
||
def __init__(self, name: str, food: str) -> None: | ||
self.name = name | ||
self.food = food | ||
|
||
def __str__(self) -> str: | ||
return self.name | ||
|
||
def watch_movie(self, movie: str) -> None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
print(f'{self.name} is watching "{movie}".') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
CinemaBar
class is instantiated, but sincesell_product
is a static method, you don't need to create an instance ofCinemaBar
to call it. You can call it directly usingCinemaBar.sell_product(customer=customer, product=customer.food)
.