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

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

solution #1432

wants to merge 1 commit into from

Conversation

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

Your code is well-structured and meets the core requirements of the task. 🎉 There are a couple of minor improvements you can make: ensure the take_damage method checks if the animal is in the alive list before removing it, and adjust the __str__ method to be an instance method instead of a class method. Keep up the great work and happy coding! 😊

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

Comment on lines +24 to +25
@classmethod
def __str__() -> str:

Choose a reason for hiding this comment

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

The __str__ method should not be a class method. It should be an instance method to provide a string representation of an instance of the class. Consider removing the @classmethod decorator and adjusting the method accordingly.

def take_damage(self) -> None:
self.health -= 50
if self.health <= 0:
Animal.alive.remove(self)

Choose a reason for hiding this comment

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

In the take_damage method, before removing self from Animal.alive, you should check if self is actually in the list to prevent potential errors. Consider using a condition like if self in Animal.alive: before attempting to remove it.

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