-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 #1422
base: master
Are you sure you want to change the base?
Solution #1422
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.
It looks like there are a few critical issues that need to be addressed before we can approve the Pull Request. The typos in the hide
method of the Herbivore
class and the bite
method of the Carnivore
class need to be corrected to ensure the code functions as expected. Additionally, the logic in the bite
method should be revised to handle hidden victims appropriately. Once these issues are resolved, the code will be in great shape! Keep up the good work, and don't hesitate to reach out if you need any help. 😊
✨ 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
class Herbivore(Animal): | ||
def hide(self) -> bool: | ||
self.hidden = not self.hidden | ||
return self.hiden |
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.
There is a typo in the return statement. It should be self.hidden
instead of self.hiden
.
app/main.py
Outdated
def bite(self, victim: Herbivore) -> bool: | ||
if isinstance(victim, Carnivore): | ||
print('Carnivore cannot bite by another carnivore!') | ||
elif not victim.hiden: |
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.
There is a typo here. It should be victim.hidden
instead of victim.hiden
.
app/main.py
Outdated
elif victim.hidden: | ||
victim.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 victim is hidden, their health should not be reset to 100. Consider revising this logic to reflect the intended behavior when a hidden victim is bitten.
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.
Review Summary
Great effort on your submission! 🎉 Your code meets most of the task requirements, but there are a few critical issues that need to be addressed to enhance functionality and adhere to the task constraints:
-
Carnivore Class - Bite Method: The
bite
method currently checks if the victim is aCarnivore
, which seems incorrect. It should check if the victim is aHerbivore
since carnivores typically prey on herbivores. Additionally, ensure that the method returns a boolean indicating whether the bite was successful. -
Animal Class - Alive Attribute: Ensure that the
Animal.alive
attribute only contains living animals. The current implementation does not handle the case where an animal is initialized with health less than or equal to zero, which could lead to dead animals being added toAnimal.alive
. -
Printing Alive Animals: The
print_alive
method should match the required output format. It currently returns a list of dictionaries but does not print them in the specified format. -
Code Style: Make sure all string literals use double quotes to adhere to the style guide.
Your decision to approve this Pull Request is to help you move forward with your learning journey. However, it's crucial to address these issues in future iterations to avoid similar problems. Keep up the good work, and use this feedback to refine your skills and improve your code! 🚀
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
|
||
class Carnivore(Animal): | ||
def bite(self, victim: Herbivore) -> bool: | ||
if isinstance(victim, 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.
The condition isinstance(victim, Carnivore)
seems incorrect for the bite
method. The method should check if the victim is a Herbivore
, not a Carnivore
, since a carnivore should be able to bite herbivores, not other carnivores. Consider revising this condition.
No description provided.