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 #1412

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

Solution #1412

wants to merge 4 commits into from

Conversation

Professor-Douel
Copy link

No description provided.

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.

Your code is well-structured and meets the task requirements effectively! 🎉 The class hierarchy and methods are implemented correctly, and you've done a great job managing the list of alive animals. While there are a couple of minor naming suggestions to improve clarity—like renaming print_alive to get_alive and adjusting the __str__ method for better alignment with its typical use—these do not impact the functionality. Keep up the great work, and consider these suggestions for future improvements! 😊

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

app/main.py Outdated
Comment on lines 22 to 23
@classmethod
def __str__(cls) -> str:

Choose a reason for hiding this comment

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

The __str__ method is typically used to provide a string representation of an instance, not a class. Consider renaming this method to something more appropriate, like get_alive_repr, to avoid confusion.

app/main.py Outdated
Comment on lines 27 to 28
def print_alive(cls) -> list:
return cls.alive

Choose a reason for hiding this comment

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

The method print_alive returns a list of alive animals, but the name suggests it prints something. Consider renaming it to get_alive to better reflect its functionality.

app/main.py Outdated
Comment on lines 4 to 7
def __init__(self,
name: str,
health: int = 100
) -> None:

Choose a reason for hiding this comment

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

Fix code style, if you specify a parameter on a line with (, then the last parameter must have a ) !
2 options:
def init(self,
name: str,
health: int = 100) -> None:

def init(
self,
name: str,
health: int = 100
) -> None:

Choose a reason for hiding this comment

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

Read please checklist (point 5) before pushing your solution.

app/main.py Outdated

class Carnivore(Animal):
@staticmethod
def bite(other: "Animal") -> None:

Choose a reason for hiding this comment

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

If you do not have any problems importing this class, you do not need to use “Animal”, just Animal

app/main.py Outdated
other.health -= 50
if other.health <= 0:
other.health = 0
Animal.remove_dead()

Choose a reason for hiding this comment

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

Using this method, you remove all animals with less than 0 health from the list at once, and I don't think this is right.
It would be more logical to remove a specific instance of an animal that was killed from the list, for example:
Animal.alive.remove(other)
or super().alive.remove(other)

app/main.py Outdated

class Carnivore(Animal):
@staticmethod
def bite(other: "Animal") -> None:

Choose a reason for hiding this comment

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

other is not a good variable naming. In my opinion, better would be something like "target".

app/main.py Outdated
if isinstance(target, Herbivore) and not target.hidden:
target.health -= 50
if target.health <= 0:
target.health = 0

Choose a reason for hiding this comment

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

looks like we don't need this assign

app/main.py Outdated
Comment on lines 4 to 6
def __init__(self,
name: str,
health: int = 100) -> None:

Choose a reason for hiding this comment

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

One attribute per line, when you have a lot of attributes. At checklist you have a good example of styling
def long_function_name(
        var_one,
        var_two,
        var_three,
        var_four
) -> None:

app/main.py Outdated
Comment on lines 17 to 27
@classmethod
def remove_dead(cls) -> None:
cls.alive = [animal for animal in cls.alive if animal.health > 0]

@classmethod
def get_alive_repr(cls) -> str:
return str([repr(animal) for animal in cls.alive])

@classmethod
def get_alive(cls) -> list:
return cls.alive

Choose a reason for hiding this comment

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

these methods isn't needed due to task requirements

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.

GJ 👍

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