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

Develop #1439

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

Develop #1439

wants to merge 3 commits into from

Conversation

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


Hello! 😊 You've done a great job implementing the class hierarchy for animals and following object-oriented principles. However, there are a couple of critical issues that need to be addressed before we can approve the pull request:

  1. __del__ Method Usage: The current implementation of the __del__ method is not reliable for removing animals from the Animal.alive list when their health reaches 0. This is because the __del__ method is not guaranteed to be called, especially when the program exits. It's important to use a more reliable mechanism to manage the alive list, such as explicitly removing the animal when its health reaches 0.

  2. Printing Animal.alive: The task requires that printing Animal.alive should show a list of dictionaries. The current implementation does not meet this requirement. Please adjust the __str__ or __repr__ methods to ensure the output is formatted as expected.

These changes are crucial for the functionality and requirements of the task. Once you address these issues, your code will be in great shape! Keep up the good work, and don't hesitate to reach out if you need any help. 🌟

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

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

app/main.py Outdated Show resolved Hide resolved
app/main.py Show resolved Hide resolved
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.

Review Summary

Great job on addressing the previous issues and implementing the cleanup_dead_animals method to manage the Animal.alive list. Your code meets most of the task requirements, and the class hierarchy is well-structured with Herbivore and Carnivore inheriting from Animal. The hide and bite methods are implemented correctly. 🎉

However, there are a few critical issues to address:

  1. Automatic Removal of Dead Animals: Currently, the cleanup_dead_animals method requires manual invocation. To fully meet the task requirements, ensure that animals are automatically removed from the Animal.alive list when their health reaches 0.

  2. Animal.alive Representation: The __str__ and __repr__ methods should be adjusted to return a dictionary format instead of a string. This will ensure that printing Animal.alive shows a list of dictionaries as required.

Your efforts are commendable, and these adjustments will enhance the functionality of your code. Keep up the good work and continue learning from these experiences! 🚀

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

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

Choose a reason for hiding this comment

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

The __str__ method should be adjusted to return a dictionary format instead of a string. The task requires that printing Animal.alive should show a list of dictionaries.

Comment on lines +25 to +26
def __repr__(self) -> str:
return str(self)

Choose a reason for hiding this comment

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

The __repr__ method currently returns the same string as __str__. Consider modifying it to ensure that the Animal.alive list is printed as a list of dictionaries.

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