Skip to content
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 #1439

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Solution #1439

wants to merge 3 commits into from

Conversation

serg121192
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on your code! 😃 There are just a few areas that need a bit of polishing. Remember to add docstrings to your classes and methods for better readability and maintainability. Consider using more descriptive method names and efficient list comprehensions. Also, try to adhere to the Single Responsibility Principle and Dependency Inversion Principle for better code structure. Keep up the good work and happy coding!

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

Comment on lines +5 to +9
class CinemaHall:
def __init__(
self,
number: int
) -> None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class named CinemaHall has only one attribute number. It is a good practice to have more attributes that define the state of the object. For example, you can add attributes like seats, screen_size, sound_system, etc. to make it more representative of a real cinema hall.

Comment on lines +12 to +22
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)
print(f'"{movie_name}" ended.')
cleaning_staff.clean_hall(self.number)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The movie_session method seems to be doing too much. It is not only responsible for starting and ending the movie session, but also for making each customer watch the movie and making the cleaning staff clean the hall. This violates the Single Responsibility Principle. Consider splitting this method into several methods, each with a single responsibility. For example, you can create a start_session method, a end_session method, a watch_movie method in the Customer class, and a clean_hall method in the Cleaner class.

Comment on lines +13 to +17
self,
movie_name: str,
customers: list[Customer],
cleaning_staff: Cleaner
) -> None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The movie_session method accepts a list of Customer objects and a Cleaner object as parameters. This means that the CinemaHall class is tightly coupled with the Customer and Cleaner classes, which is not a good practice. Consider using the Dependency Inversion Principle to make your code more flexible and maintainable. This principle states that high-level modules should not depend on low-level modules. Both should depend on abstractions. In this case, you can create an abstract Person class and make both Customer and Cleaner inherit from it. Then you can make the CinemaHall class depend on the Person class instead of Customer and Cleaner.

Comment on lines +7 to +11
def cinema_visit(
customers: list,
hall_number: int,
cleaner: str,
movie: str

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function cinema_visit lacks a docstring. It's a good practice to include docstrings in your functions to describe their behavior, arguments, return values, and any exceptions they raise. This makes your code easier to understand and maintain.

app/main.py Outdated
Comment on lines 13 to 15
visitors = []
for customer in customers:
visitors.append(Customer(customer["name"], customer["food"]))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're creating Customer objects within a loop and appending them to the visitors list. This is not efficient and can be improved. Consider using a list comprehension to create these objects in a single line of code. This would make your code cleaner and more Pythonic.

app/main.py Outdated
cinema_bar = CinemaBar()
cleaning_staff = Cleaner(cleaner)
for visitor in visitors:
cinema_bar.sell_product(visitor.food, visitor)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you are calling the sell_product method of cinema_bar object. It's not clear from the method name what it does. Consider renaming it to something more descriptive, like sell_food_to_visitor, to improve the readability of your code.

cleaning_staff = Cleaner(cleaner)
for visitor in visitors:
cinema_bar.sell_product(visitor.food, visitor)
cinema_hall.movie_session(movie, visitors, cleaning_staff)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The movie_session method is being called here, but it's not clear what it does just by its name. Consider renaming it to something more descriptive, like start_movie_session, to improve the readability of your code.

app/main.py Outdated
cinema_bar = CinemaBar()
cleaning_staff = Cleaner(cleaner)
for visitor in visitors:
cinema_bar.sell_product(visitor.food, visitor)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to have instance of CinemaBar. You can use class CinemaBar directly as sell_product method is static method

@@ -0,0 +1,8 @@
from __future__ import annotations

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose you don't need this import

Copy link

@LLkaia LLkaia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants