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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Solution #1298

wants to merge 1 commit into from

Conversation

Le0n-K
Copy link

@Le0n-K Le0n-K commented Oct 7, 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 your code! 🎉 There are a few areas that could be improved for efficiency and cleanliness, but these are minor issues and do not impact the core functionality of your code. Keep up the good work and consider the provided feedback for your future coding tasks. Happy coding! 😊

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


class Carnivore(Animal):
@classmethod
def bite(cls, herbivore: Animal) -> None:

Choose a reason for hiding this comment

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

Code Efficiency: You should use the class name to get access to the class attributes. In this case, instead of cls.alive.remove(herbivore), you should use Animal.alive.remove(herbivore). Refer to point 1 in the checklist.


class Herbivore(Animal):
def hide(self) -> None:
self.hidden = not self.hidden

Choose a reason for hiding this comment

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

Code Efficiency: You can change the bool value in one line without using an if statement. In this case, you should use self.hidden = not self.hidden. Refer to point 2 in the checklist.

Comment on lines +24 to +29
def bite(cls, herbivore: Animal) -> None:
if isinstance(herbivore, Herbivore) and not herbivore.hidden:
herbivore.health -= 50

if herbivore.health <= 0:
cls.alive.remove(herbivore)

Choose a reason for hiding this comment

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

Code Efficiency: This method could be a static method since it doesn't use any instance attributes. Refer to point 3 in the checklist.

Comment on lines +16 to +19
def __repr__(self) -> str:
return (f"{{Name: {self.name}, "
f"Health: {self.health}, "
f"Hidden: {self.hidden}}}")

Choose a reason for hiding this comment

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

Code Style: You should use interpolation instead of concatenation. In this case, instead of f"{{Name: {self.name}, ", you should use f"{{Name: {self.name}, ". Refer to point 3 in the checklist.

Comment on lines +7 to +13
def __init__(self,
name: str,
heals: int = 100,
hidden: bool = False) -> None:
self.name = name
self.health = heals
self.hidden = hidden

Choose a reason for hiding this comment

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

Code Style: You should use descriptive and correct variable names. In this case, instead of heals, you should use health. Refer to point 4 in the checklist.

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