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

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

Conversation

veronica-shyian
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.

Thank you for your hard work on this task! 😊 While your implementation is mostly correct, there are a couple of critical issues that need to be addressed to fully meet the task requirements.

  1. In the Carnivore class, the bite method should verify that the animal is an instance of Herbivore and is not hidden. This can be achieved using a single if statement like if (animal instanceof Herbivore && !animal.hidden). This ensures the method behaves as expected according to the task requirements.

  2. When removing dead animals from the Animal.alive array, it's recommended to use the filter method instead of splice. This approach is more efficient and aligns with the checklist requirement to avoid nesting loops.

Once these issues are resolved, your code will be in great shape! Keep up the great work, and don't hesitate to reach out if you have any questions or need further assistance. 🌟

✨ 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.

Comment on lines 26 to 27
bite(animal) {
if (animal.hidden === false) {

Choose a reason for hiding this comment

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

The bite method should check if the animal is an instance of Herbivore and not hidden. You can use if (animal instanceof Herbivore && !animal.hidden) to ensure the correct condition.

Comment on lines 30 to 33
if (animal.health === 0) {
const index = Animal.alive.indexOf(animal);

Animal.alive.splice(index, 1);

Choose a reason for hiding this comment

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

Instead of using splice to remove the animal from the Animal.alive array, it's preferred to use the filter method to remove animals with health less than or equal to 0. This aligns with the checklist requirement.

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.

Great job on implementing the Animal, Herbivore, and Carnivore classes! 🎉 Your code meets the task requirements and constraints effectively. The Herbivore class correctly implements the hide method, and the Carnivore class's bite method is well-implemented, checking if the target is a Herbivore and not hidden. The use of the filter method to manage the Animal.alive array is efficient and aligns with the checklist.

While there are no changes needed at this point, remember to review any comments provided to further enhance your code quality. Keep up the good work, and continue learning from each task. If any critical issues arise in future tasks, ensure they are addressed to maintain the functionality and quality of your code. Keep coding and improving! 🚀

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

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.

2 participants