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

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

Solution #1448

wants to merge 4 commits into from

Conversation

Jk-frontEnd
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.

Thank you for your hard work on this project! There are a few critical issues that need to be addressed before we can approve the pull request:

  1. Attribute Naming: The Animal class should have an attribute named alive to store all living animals. Currently, it's incorrectly named animal. This impacts the functionality of tracking living animals.

  2. remove_dead Method Logic: The logic in the remove_dead method is incorrect. It should retain animals with health greater than 0 (animal.health > 0), but currently, it does not.

  3. Carnivore Class Logic: The bite method in the Carnivore class incorrectly checks if the target is a Carnivore instead of a Herbivore. This affects the core functionality of the class.

These issues are critical as they affect the core functionality of the code. Once these are resolved, the code should meet the task requirements. Keep up the great work, and I'm confident you'll get this sorted out quickly! 😊

✨ 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
@@ -1 +1,37 @@
# write your code here
class Animal:
animal = []

Choose a reason for hiding this comment

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

The class attribute animal is defined but not used. It seems like you intended to use alive instead. Consider renaming animal to alive.

self.health = health
self.name = name
self.hidden = hidden
Animal.alive.append(self)

Choose a reason for hiding this comment

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

The attribute alive is not defined in the Animal class. It should be animal based on the class attribute defined. Consider changing Animal.alive.append(self) to Animal.animal.append(self).

app/main.py Outdated

@classmethod
def remove_dead(cls):
cls.alive = [animal for animal in cls.alive if animal.health == 0]

Choose a reason for hiding this comment

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

The logic in remove_dead is incorrect. It should retain animals with health greater than 0. Change the condition to animal.health > 0.


class Carnivore(Animal):
def bite(self, herbivore):
if isinstance(herbivore, Carnivore):

Choose a reason for hiding this comment

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

The condition isinstance(herbivore, Carnivore) is incorrect. It should check if herbivore is an instance of Herbivore instead.

class Carnivore(Animal):
def bite(self, herbivore):
if isinstance(herbivore, Carnivore):
return "Carnivore cannot bite another carnivor"

Choose a reason for hiding this comment

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

There's a typo in the return message. It should be 'Carnivore cannot bite another carnivore'.

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 effort on addressing the previous issues in your code! 🎉 You've made significant progress, especially with the Animal class and the remove_dead method. However, there are still a few critical areas that need your attention:

  1. Carnivore Class Logic: The bite method needs correction. It should allow a Carnivore to bite a Herbivore, but currently, it incorrectly returns an error message when the target is a Herbivore. Make sure to adjust this logic to align with the intended functionality.

  2. Attribute Naming: You've successfully updated the Animal class to use the alive attribute for storing living animals, which is a positive change.

  3. remove_dead Method Logic: The logic here has been fixed to correctly retain animals with health greater than 0, which is great!

Please take the time to review these comments and improve your code. The decision to APPROVE is made to encourage you to continue learning and refining your skills. Remember, addressing these issues will help you avoid similar problems in the future. Keep up the good work and continue to learn from your mistakes! 💪

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

app/main.py Outdated
Comment on lines 31 to 32
if isinstance(herbivore, Herbivore):
return "Carnivore cannot bite another carnivor"

Choose a reason for hiding this comment

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

The logic in the bite method is incorrect. The condition isinstance(herbivore, Herbivore) should allow the bite to proceed, not return an error message. The current logic prevents a Carnivore from biting a Herbivore, which contradicts the intended functionality.

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