-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
implemented #1336
base: master
Are you sure you want to change the base?
implemented #1336
Conversation
-class Animal -class Herbivore -class Carnivore
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.
Great job on implementing the Animal
class and its subclasses! 🎉 Your code meets the core requirements, and the functionality is well-implemented. While there are a few minor improvements suggested, such as adding type annotations for clarity, these do not impact the functionality. Keep up the good work, and consider incorporating the feedback to enhance your code quality further! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
app/main.py
Outdated
@@ -1 +1,26 @@ | |||
# 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 is a class variable, which is appropriate for tracking all instances of Animal
. Ensure that this list is managed carefully to avoid potential issues with object references, especially when instances are deleted or go out of scope.
|
||
class Herbivore(Animal): | ||
def hide(self): | ||
self.hidden = not self.hidden |
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 hide
method toggles the hidden
state of the Herbivore
. This is correct, but ensure that the logic for hiding is consistent with the intended behavior of the application.
|
||
class Carnivore(Animal): | ||
def bite(self, animal): | ||
if isinstance(animal, Herbivore) and not animal.hidden: |
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 bite
method correctly checks if the animal
is an instance of Herbivore
and not hidden before reducing its health. This logic is appropriate for the intended functionality.
-class Animal
-class Herbivore
-class Carnivore