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' #1397

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

'Solution' #1397

wants to merge 10 commits into from

Conversation

Dogober
Copy link

@Dogober Dogober commented Dec 6, 2024

No description provided.

Copy link

@taraskhom taraskhom left a comment

Choose a reason for hiding this comment

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

Everything is all right but you can simplify bite method by using and statement

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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

There are no files to review. Please make sure that you have added files to the pull request. Some files and directories may be ignored from the review or failed to load.
[CODE: 4]

Additional info:
Ignored files list:

  • app/main.py

If the issue is within your control, please address it.
The next review attempt will automatically launch in 1 hour.
If you believe this is an error or need assistance, please contact the support team.

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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

There are no files to review. Please make sure that you have added files to the pull request. Some files and directories may be ignored from the review or failed to load.
[CODE: 4]

Additional info:
Ignored files list:

  • app/main.py

If the issue is within your control, please address it.
The next review attempt will automatically launch in 1 hour.
If you believe this is an error or need assistance, please contact the support team.

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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

There are no files to review. Please make sure that you have added files to the pull request. Some files and directories may be ignored from the review or failed to load.
[CODE: 4]

Additional info:
Ignored files list:

  • app/main.py

If the issue is within your control, please address it.
The next review attempt will automatically launch in 1 hour.
If you believe this is an error or need assistance, please contact the support team.

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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

There are no files to review. Please make sure that you have added files to the pull request. Some files and directories may be ignored from the review or failed to load.
[CODE: 4]

Additional info:
Ignored files list:

  • app/main.py

If the issue is within your control, please address it.
The next review attempt will automatically launch in 1 hour.
If you believe this is an error or need assistance, please contact the support team.

app/main.py Outdated
Comment on lines 28 to 31
if not self.hidden:
self.hidden = True
return
self.hidden = False
Copy link

Choose a reason for hiding this comment

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

It can be a one-liner, please read a checklist!

app/main.py Outdated
class Carnivore(Animal):

@staticmethod
def bite(other: Union[Carnivore, Herbivore]) -> Union[str, None]:
Copy link

Choose a reason for hiding this comment

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

You can simply use str | None, without Union, it's not needed here

app/main.py Outdated
return "Carnivore won't bit Carnivore"
if isinstance(other, Herbivore) and other.hidden:
return "Carnivore won't be able to bite hidden Herbivore"
if other.health > 0:
Copy link

Choose a reason for hiding this comment

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

Do you need this check? Every bite it is -50,it looks like not required here

app/main.py Outdated
Comment on lines 14 to 22
def __str__(self) -> str:

return (f"Name: {self.name}, "
f"Health: {self.health}, "
f"Hidden: {self.hidden}")

def __repr__(self) -> str:

return f"{{{self}}}"
Copy link

Choose a reason for hiding this comment

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

It looks like you need to use only repr

app/main.py Outdated
Comment on lines 38 to 41
if isinstance(other, Carnivore):
return "Carnivore won't bit Carnivore"
if isinstance(other, Herbivore) and other.hidden:
return "Carnivore won't be able to bite hidden Herbivore"
Copy link

Choose a reason for hiding this comment

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

At task we don't have requirements to return some text.

Carnivore has a bite method, which takes a herbivore object and decreases the object's health by 50. The method does not work if it is another сarnivore, or the herbivore is currently hiding.

@Dogober Dogober requested a review from L1nk3rrr December 10, 2024 07:19
app/main.py Outdated
Comment on lines 31 to 37
if isinstance(other, Carnivore):
return
if isinstance(other, Herbivore) and other.hidden:
return
other.health -= 50
if other.health <= 0:
Animal.alive.pop(Animal.alive.index(other))

Choose a reason for hiding this comment

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

at task you need to check only for is other instance of Herbivore and not hidden.
So you don't need return at all, simplify this method

Copy link
Author

Choose a reason for hiding this comment

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

The method does not work if it is another сarnivore, or the herbivore is currently hiding. This is from condition of the task

Copy link
Author

Choose a reason for hiding this comment

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

So I finally understand what exactly did you mean

app/main.py Outdated
Comment on lines 31 to 37
if isinstance(other, Carnivore):
return
if isinstance(other, Herbivore) and other.hidden:
return
other.health -= 50
if other.health <= 0:
Animal.alive.pop(Animal.alive.index(other))

Choose a reason for hiding this comment

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

Also at 37 line Animal.alive.pop(Animal.alive.index(other))

Simplify this line. We access class attributes through class name and it's better to use remove when value is given and del when an index is given. You do unnecessary work here

app/main.py Outdated
class Carnivore(Animal):

@staticmethod
def bite(other: Union[Carnivore, Herbivore]) -> None:

Choose a reason for hiding this comment

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

at can be simlified to Animal, as all of them is child of Animal, don't needed Union

@Dogober Dogober requested a review from L1nk3rrr December 10, 2024 18:49
app/main.py Outdated
Comment on lines 14 to 18
return (f"{{"
f"Name: {self.name}, "
f"Health: {self.health}, "
f"Hidden: {self.hidden}}}")

Choose a reason for hiding this comment

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

If you have already put these brackets in a separate line, do the same at the end, or vice versa.

@Dogober Dogober requested a review from petrykivd December 11, 2024 17:47
Copy link

@petrykivd petrykivd left a comment

Choose a reason for hiding this comment

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

Nice! 😎

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.

5 participants