-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 #1430
base: master
Are you sure you want to change the base?
Solution #1430
Changes from 1 commit
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,6 @@ | ||
class CinemaBar: | ||
|
||
|
||
@staticmethod | ||
def sell_product(product: str, customer) -> str: | ||
print(f"Cinema bar sold {product} to {customer.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. This function seems to be incomplete. It only prints a message but does not do anything else. Consider adding functionality to actually sell the product, for example, by decrementing the product from the bar's stock and adding it to the customer's purchases. 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. You are calling 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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from app.people.cinema_staff import Cleaner | ||
|
||
class CinemaHall: | ||
|
||
|
||
def __init__(self, number: int): | ||
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 |
||
self.number = number | ||
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. It's a good practice to validate input data. In this case, you should check if the |
||
|
||
def movie_session(self, movie_name, customers: list, cleaning_staff) -> str: | ||
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 type of |
||
# clin_name = Cleaner(cleaning_staff) | ||
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. It's assumed that |
||
print(f"\"{movie_name}\" ended.") | ||
cleaning_staff.clean_hall(self.number) | ||
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 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. Here, |
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,25 @@ | ||
# 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 | ||
def cinema_visit( | ||
customers: list, | ||
hall_number: int, | ||
cleaner: str, | ||
movie: str | ||
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 |
||
) -> 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 function """ Parameters:
|
||
name_and_food = [ | ||
Customer(customer["name"], customer["food"]) | ||
for customer in customers | ||
] | ||
cinema_bar = CinemaBar() | ||
hall = CinemaHall(hall_number) | ||
name_cleaner = Cleaner(cleaner) | ||
|
||
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 creation of the |
||
for customer in name_and_food: | ||
cinema_bar.sell_product(customer.food, customer) | ||
|
||
Comment on lines
+32
to
+33
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. This loop could potentially raise an exception if the |
||
hall.movie_session(movie, name_and_food, name_cleaner) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Cleaner: | ||
|
||
|
||
def __init__(self, name: str): | ||
self.name = 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. It's a good practice to use type annotations for instance variables, not only for function arguments. This will make your code more readable and will help other developers understand what type of data should be stored in the variable. You can add it like this: |
||
|
||
def clean_hall(self, hall_number: int) -> str: | ||
print(f"Cleaner {self.name} is cleaning hall number {hall_number}.") | ||
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 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. Instead of using the |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class Customer: | ||
|
||
|
||
def __init__(self, name: str, food: str): | ||
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. It's a good practice to include a docstring at the beginning of the class to describe its purpose. This makes your code more readable and maintainable. |
||
self.name = name | ||
self.food = food | ||
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. Docstrings are also recommended for methods to explain what they do. In this case, you should explain what the init method is doing and what the parameters 'name' and 'food' are. |
||
|
||
def watch_movie(self, movie: str) -> str: | ||
print(f"{self.name} is watching \"{movie}\".") | ||
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 'watch_movie' method currently doesn't return anything, but the function signature suggests it should return a string. If you want this method to return a string, you should use the 'return' statement instead of 'print'. If you intended to only display the message, you should remove '-> str' from the function signature. |
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.
This function has a return type hint of
str
, but does not return anything. This can lead to confusion for other developers who use this function, expecting it to return a string. If there is nothing to return, you should remove the return type hint.