-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
base: master
Are you sure you want to change the base?
Solution 2 #1327
Conversation
There was a problem hiding this 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:
-
Class Variable Access: The
alive
list should be a class variable, not an instance variable. It should be defined asAnimal.alive = []
outside of the class definition to ensure it is shared across all instances. Make sure to useAnimal.alive
instead ofself.alive
when appending or removing animals. -
Class Name Character: The class name
Сarnivore
uses a non-standard character for 'C'. Please correct this to avoid potential issues. -
Logic in
bite
Method: The logic in thebite
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 = [] |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
No description provided.