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' #1579

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

'Solution' #1579

wants to merge 1 commit into from

Conversation

strauuch
Copy link

@strauuch strauuch commented Mar 7, 2025

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 implementing the Animal, Carnivore, and Herbivore classes! 🎉 Your code meets the task requirements and constraints effectively. The class structure and inheritance are well done, and the methods are implemented correctly. The use of the alive list as a class variable is appropriate for tracking all living animals, and your logic for the bite and hide methods aligns with the intended game mechanics.

Keep up the good work, and consider the feedback on the alive list if you ever need to change the scope of tracking in future projects. Happy coding! 😊

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

@@ -1 +1,29 @@
# write your code here
class Animal:
alive = []

Choose a reason for hiding this comment

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

The alive list is a class variable, meaning it is shared across all instances of Animal. If the intention is to track all living animals, this is correct. However, if each instance should have its own list, consider making it an instance variable instead.


class Carnivore(Animal):
def bite(self, herbivore):
if isinstance(herbivore, Herbivore) and not herbivore.hidden:

Choose a reason for hiding this comment

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

The condition not herbivore.hidden is correctly checking if the herbivore is not hidden before allowing the carnivore to bite. Ensure that this logic aligns with the intended game mechanics.

if isinstance(herbivore, Herbivore) and not herbivore.hidden:
herbivore.health -= 50
if herbivore.health <= 0:
Animal.alive.remove(herbivore)

Choose a reason for hiding this comment

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

Removing the herbivore from Animal.alive when its health is less than or equal to zero is correct. Ensure that this logic is consistent with the intended behavior for when an animal 'dies'.

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