-
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 #701
base: master
Are you sure you want to change the base?
Solution #701
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.
nice, good idea with "die_animal" method
app/main.py
Outdated
class Carnivore(Animal): | ||
|
||
def bite(self, herbivore: Animal) -> None: | ||
if isinstance(herbivore, Herbivore): |
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.
u can do it in one if statement
app/main.py
Outdated
if not herbivore.hidden: | ||
herbivore.health -= 50 | ||
|
||
if herbivore.health <= 0: |
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.
better move its statement inside in previous if
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.
you mean to move
if herbivore.health <= 0:
herbivore.die_animal()
inside
if isinstance(herbivore, Herbivore) and not herbivore.hidden:
herbivore.health -= 50
Like that
if isinstance(herbivore, Herbivore) and not herbivore.hidden:
if herbivore.health <= 0:
herbivore.die_animal()
herbivore.health -= 50
Or not?
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.
yeah, well done 🚀
No description provided.