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 2 #1327

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

Solution 2 #1327

wants to merge 2 commits into from

Conversation

IllyaKovaliuk
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 submission! Your code is on the right track, but there are a few critical issues that need to be addressed before it can be approved:

  1. Class Variable Access: The alive list should be a class variable, not an instance variable. It should be defined as Animal.alive = [] outside of the class definition to ensure it is shared across all instances. Make sure to use Animal.alive instead of self.alive when appending or removing animals.

  2. Class Name Character: The class name Сarnivore uses a non-standard character for 'C'. Please correct this to avoid potential issues.

  3. Logic in bite Method: The logic in the bite method seems incorrect when the target is hidden. If the target is hidden, its health should not be reset to 100. Please revise this logic.

These changes are necessary to ensure the functionality and consistency of your code. Once you've made these adjustments, feel free to resubmit. Keep up the great work! 🌟

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

@@ -1 +1,54 @@
# 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 should be a class variable, not an instance variable. It should be defined as Animal.alive = [] outside of the class definition to ensure it is shared across all instances.

app/main.py Outdated
self.name = name
self.health = health
self.is_hidden = is_hidden
self.alive.append(self)

Choose a reason for hiding this comment

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

Appending self to self.alive is incorrect because alive should be accessed as a class variable. Use Animal.alive.append(self) instead.

app/main.py Outdated

def die(self):
if self in Animal.alive:
self.alive.remove(self)

Choose a reason for hiding this comment

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

Similar to the constructor, alive should be accessed as a class variable. Use Animal.alive.remove(self) instead.

app/main.py Outdated
return self.is_hidden


class Сarnivore(Animal):

Choose a reason for hiding this comment

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

The class name Сarnivore uses a non-standard character for 'C'. Ensure you are using the correct 'C' character to avoid potential issues.

app/main.py Outdated
target.health = 0
target.die()
else:
target.health = 100

Choose a reason for hiding this comment

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

The logic here seems incorrect. If the target is hidden, its health should not be reset to 100. Consider revising this logic.

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