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 #1430

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

Solution #1430

wants to merge 4 commits into from

Conversation

mitichd
Copy link

@mitichd mitichd commented Oct 11, 2024

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 job on the code, it's mostly well written and clean. However, there are a few areas that need improvement. Please ensure that functions with a return type in their signature do actually return a value. Also, consider splitting the movie_session method into several smaller methods for better modularity. Don't forget to specify the type of parameters in the method signature and add docstrings for better readability. Keep up the good work! 👍

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



@staticmethod
def sell_product(product: str, customer) -> str:

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.


@staticmethod
def sell_product(product: str, customer) -> str:
print(f"Cinema bar sold {product} to {customer.name}.")

Choose a reason for hiding this comment

The 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.

Comment on lines 9 to 15
def movie_session(self, movie_name, customers: list, cleaning_staff) -> str:
# clin_name = Cleaner(cleaning_staff)
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 is doing too many things - it's starting the movie, making customers watch the movie, and then cleaning the hall. Consider splitting this method into several smaller methods, each with a single responsibility. This will make your code more modular and easier to maintain.

def __init__(self, number: int):
self.number = number

def movie_session(self, movie_name, customers: list, cleaning_staff) -> str:

Choose a reason for hiding this comment

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

The type of movie_name and cleaning_staff parameters are not specified. It's a good practice to always specify the type of parameters in the method signature. This makes the code more readable and prevents potential bugs caused by unexpected data types.

class CinemaHall:


def __init__(self, number: int):

Choose a reason for hiding this comment

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

The __init__ method only initializes the number attribute of the CinemaHall class. Consider adding more attributes to this class if they are necessary for its functionality. For example, you could add a movies attribute to keep track of the movies shown in this cinema hall.

Comment on lines 7 to 8
def clean_hall(self, hall_number: int) -> str:
print(f"Cleaner {self.name} is cleaning hall number {hall_number}.")

Choose a reason for hiding this comment

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

The clean_hall method currently prints a message to the console. Consider returning the message instead of printing it. This would make your code more testable and reusable, as you can handle the returned message in whatever way you want outside of this method. For example, you may want to log this message to a file, display it in a GUI, etc. If you return the message, you can decide on the handling of the message outside of this method.

class Customer:


def __init__(self, name: str, food: str):

Choose a reason for hiding this comment

The 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.

Comment on lines 4 to 6
def __init__(self, name: str, food: str):
self.name = name
self.food = food

Choose a reason for hiding this comment

The 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.

Comment on lines 8 to 9
def watch_movie(self, movie: str) -> str:
print(f"{self.name} is watching \"{movie}\".")

Choose a reason for hiding this comment

The 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.

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.

You've done a great job so far! 🌟 However, there are a few areas that need your attention. Please consider the feedback provided to improve your function annotations, add necessary validations, and ensure the correct use of the return statement. Keep up the good work! 💪

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


@staticmethod
def sell_product(product: str, customer: str) -> str:
print(f"Cinema bar sold {product} to {customer.name}.")

Choose a reason for hiding this comment

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

You are calling customer.name assuming customer is an object, but according to your function signature, you are expecting a string. Make sure to pass the correct arguments to your function. Also, instead of printing the string, it would be better to return it, so you can use the result elsewhere if needed.

class CinemaHall:

def __init__(self, number: int) -> None:
self.number = number

Choose a reason for hiding this comment

The 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 number is a positive integer.

def __init__(self, number: int) -> None:
self.number = number

def movie_session(

Choose a reason for hiding this comment

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

This method does a lot of things: it starts a movie session, makes customers watch the movie, and cleans the hall. It might be better to split this functionality into separate methods for better code organization and readability. Also, the method name movie_session doesn't clearly reflect what it does. Consider renaming it to something more descriptive.

) -> str:
print(f"\"{movie_name}\" started in hall number {self.number}.")
for customer in customers:
customer.watch_movie(movie_name)

Choose a reason for hiding this comment

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

It's assumed that customers is a list of Customer objects, but there's no validation of this. It's a good practice to check the type of elements in the list.

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.

Here, cleaning_staff is a string, but it's used as an object with a clean_hall method. It seems like a mistake.

app/main.py Outdated
Comment on lines 7 to 12
def cinema_visit(
customers: list,
hall_number: int,
cleaner: str,
movie: str
) -> None:

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 important to provide a clear description of what your function does, what parameters it expects, and what it returns (if anything). This is crucial for other developers who might use your function, and it's also a good practice for you to clarify your own thinking and design. Here's an example of how you might write it:

"""
Simulates a visit to the cinema.

Parameters:

  • customers (list): A list of dictionaries, where each dictionary represents a customer and contains 'name' and 'food' keys.
  • hall_number (int): The number of the hall where the movie will be shown.
  • cleaner (str): The name of the cleaner.
  • movie (str): The name of the movie to be shown.
    """
This is just a suggestion, you should adjust it according to the actual functionality of your function.

class Cleaner:

def __init__(self, name: str) -> None:
self.name = name

Choose a reason for hiding this comment

The 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: self.name: str = name.

self.name = name

def clean_hall(self, hall_number: int) -> str:
print(f"Cleaner {self.name} is cleaning hall number {hall_number}.")

Choose a reason for hiding this comment

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

Instead of using the print function to return the result, you should use the return statement. The print function is generally used for debugging or for providing information to the user, not for returning the result of a function. If you want to return a string, you should do something like this: return f'Cleaner {self.name} is cleaning hall number {hall_number}.'.

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 job so far! There are several areas for improvement mentioned in the review comments. Please pay attention to the completeness of your methods, the structure of your classes, and the use of empty lines. Also, consider adding more robustness to your code. Keep going and happy coding! 🚀

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


@staticmethod
def sell_product(product: str, customer: Customer) -> None:
"""

Choose a reason for hiding this comment

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

There are multiple empty lines here, which is against Python's PEP 8 style guide. It's recommended to have a maximum of two consecutive empty lines.

product (str): The name of the product to be sold.
customer (Customer): The customer who is buying the product.
"""
print(f"Cinema bar sold {product} to {customer.name}.")

Choose a reason for hiding this comment

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

The sell_product method currently only prints a message. It doesn't perform any action related to selling a product. Consider implementing the logic to handle the selling process, like checking product availability, deducting the product amount from the stock, checking if the customer has enough money, etc.

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.

Avoid too many empty lines. It's better to use one empty line to separate methods and two lines to separate classes.

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.

Avoid too many empty lines. It's better to use one empty line to separate methods and two lines to separate classes.

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.

Avoid too many empty lines. It's better to use one empty line to separate methods and two lines to separate classes.

"""
self.name = name

def clean_hall(self, hall_number: int) -> None:

Choose a reason for hiding this comment

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

The clean_hall method only prints a message, but it does not change the state of the cleaner. Consider adding logic to update the is_cleaning and hall attributes when this method is called.

Comment on lines +3 to +12
def __init__(self, name: str, food: str) -> None:
"""
Initializes a customer.

Parameters:
name (str): The name of the customer.
food (str): The food item the customer has.
"""
self.name = name
self.food = food

Choose a reason for hiding this comment

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

The init method has many empty lines. While it's good to have some whitespace for readability, too many empty lines can make the code look sparse and harder to read.

self.name = name
self.food = food

def watch_movie(self, movie: str) -> None:

Choose a reason for hiding this comment

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

The 'watch_movie' method is missing a docstring. Docstrings are important for understanding what a function does without having to read the code. It is a good practice to always include a docstring in your functions.

Comment on lines +14 to +21
def watch_movie(self, movie: str) -> None:
"""
Simulates the action of a customer watching a movie.

Parameters:
movie (str): The name of the movie being watched.
"""
print(f'{self.name} is watching "{movie}".')

Choose a reason for hiding this comment

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

The 'watch_movie' method has many empty lines. Please, remove unnecessary empty lines.

Parameters:
movie (str): The name of the movie being watched.
"""
print(f'{self.name} is watching "{movie}".')

Choose a reason for hiding this comment

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

The 'watch_movie' method is using 'print' to display the message. This is fine for a simple script, but for larger applications, you might want to consider using logging instead of print statements. This will give you a lot more control over when and where your output goes, and it can also provide useful additional information like timestamps.

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.

2 participants