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

solutionend #610

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

solutionend #610

wants to merge 5 commits into from

Conversation

SerhiiK05
Copy link

No description provided.

Copy link

@Mxbely Mxbely 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, but you need accept some changes

app/main.py Outdated
Comment on lines 38 to 39
def validate(self) -> None:
pass
Copy link

Choose a reason for hiding this comment

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

You can remove validate. You didn't use it

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.

Hey there! 👋 Your code is really well-structured and you're on the right track! However, there are a few improvements that need to be made before it can be approved. Specifically, don't forget to call the validate method in the SlideLimitationValidator class and consider using the @abstractmethod decorator for any abstract methods. Also, remember to add descriptive error messages when raising exceptions, this will make debugging easier in the future. Keep up the good work! 🚀

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

app/main.py Outdated
Comment on lines 17 to 20
if not isinstance(value, int):
raise TypeError
if not (self.min_amount <= value <= self.max_amount):
raise ValueError

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 provide a descriptive error message when raising an exception. This will help to debug the code if something goes wrong.

app/main.py Outdated
Comment on lines 38 to 39
def validate(self) -> None:
pass

Choose a reason for hiding this comment

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

The validate method in the SlideLimitationValidator class is not implemented. It's an abstract base class, so it's okay to have a method without an implementation, but it should be decorated with the @abstractmethod decorator to indicate that it's an abstract method and to prevent the creation of an instance of the base class.

app/main.py Outdated
Comment on lines 62 to 63
self.limitation_class(visitor.age, visitor.weight, visitor.height)
except (ValueError, TypeError):

Choose a reason for hiding this comment

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

Here you're creating an instance of the SlideLimitationValidator class (or its subclass), but you're not calling the validate method. It seems that the validate method should be called here to check if a visitor can access the slide.

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 your code so far! 👍 However, there are a few changes that need to be made. The logic within the Slide class and the SlideLimitationValidator class needs to be revised. Currently, the SlideLimitationValidator class is acting more like a data holder than a validator. I would recommend adding a validation method to this class and using it in the Slide class. Keep up the good work! 😊

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

Comment on lines 32 to +36
class SlideLimitationValidator(ABC):
pass
def __init__(self, age: int, weight: int, height: int) -> None:
self.age = age
self.weight = weight
self.height = height

Choose a reason for hiding this comment

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

The SlideLimitationValidator class is a bit confusing. It seems like it should be a class that validates the limitations for a slide. But in its current form, it's more like a data holder than a validator. You should consider adding a validation method in this class and use it in the Slide class.

app/main.py Outdated
Comment on lines 57 to 62
def can_access(self, visitor: Visitor) -> bool:
try:
self.limitation_class(visitor.age, visitor.weight, visitor.height)
except (ValueError, TypeError):
return False
return True

Choose a reason for hiding this comment

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

The can_access method in the Slide class is not working as expected. It tries to create a new instance of SlideLimitationValidator (or its child classes) with visitor's parameters. But these classes don't validate anything during the initialization. I would suggest you to add a validation method in the SlideLimitationValidator class and call this method here.

app/main.py Outdated
Comment on lines 5 to 21
class IntegerRange:
pass
def __init__(self, min_amount: int, max_amount: int) -> None:
self.min_amount = min_amount
self.max_amount = max_amount

def __set_name__(self, owner: Any, name: str) -> None:
self.protected_name = "_" + name

def __get__(self, instance: Any, owner: Any) -> Any:
return getattr(instance, self.protected_name)

def __set__(self, instance: Any, value: Any) -> None:
if not isinstance(value, int):
raise TypeError(f"{value} should be integer!")
if not (self.min_amount <= value <= self.max_amount):
raise ValueError(f"{value} should be between {self.min_amount} and {self.max_amount}")
setattr(instance, self.protected_name, value)

Choose a reason for hiding this comment

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

The IntegerRange class is well implemented. It might be useful to add a docstring to describe its purpose and how it works for future reference.

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.

Your code is generally good, but there are a few issues that need to be addressed. The Slide class logic needs to be corrected and the SlideLimitationValidator class needs to actually perform validation. Despite these issues, I am approving this pull request to encourage you to continue learning and improving. Please review the comments and improve your code accordingly. Keep up the good work! 💪👍🚀

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

Comment on lines 34 to +38
class SlideLimitationValidator(ABC):
pass
def __init__(self, age: int, weight: int, height: int) -> None:
self.age = age
self.weight = weight
self.height = height

Choose a reason for hiding this comment

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

The SlideLimitationValidator class doesn't actually validate anything. It should have a method that takes a Visitor instance as a parameter and checks if the visitor meets the age, weight, and height restrictions.

Comment on lines +59 to +66
def can_access(self, visitor: Visitor) -> bool:
try:
self.limitation_class(visitor.age,
visitor.weight,
visitor.height)
except (ValueError, TypeError):
return False
return True

Choose a reason for hiding this comment

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

The can_access method is not using the SlideLimitationValidator correctly. You are trying to instantiate the SlideLimitationValidator with the visitor's age, weight, and height, but the SlideLimitationValidator doesn't actually do anything with those parameters. Instead, you should be calling a method on the SlideLimitationValidator instance that checks if the visitor meets the restrictions.

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.

3 participants