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

add herbivores and carnivores #3331

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

Conversation

ValentynaD
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! 😊 There are a couple of critical issues that need to be addressed to meet the core requirements. The hide method in the Herbivore class should set the hidden property to true instead of toggling it. Additionally, the die method should use the filter method instead of splice for better performance and to align with the checklist requirements. Please make these changes, and your solution will be ready for approval! Keep up the great work! 🚀

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

}

hide() {
this.hidden = !this.hidden;

Choose a reason for hiding this comment

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

The hide method toggles the hidden property, but according to the additional prompt rules, it should simply set this.hidden to true. Consider changing this implementation.

const index = Animal.alive.indexOf(this);

if (index !== -1) {
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.

The die method uses splice to remove the animal from the Animal.alive array. According to the checklist, it is preferred to filter animals with health less than or equal to 0 using the filter method. Consider refactoring this logic.

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.

Review Summary

Great job on implementing the task requirements! 🎉 Your code is mostly correct and aligns well with the specified constraints. Here are some highlights and areas for improvement:

  • Animal Class: You've successfully implemented the Animal class with health and name properties, and a static alive array to track living animals. This is a solid foundation for your animal hierarchy.

  • Herbivore Class: The Herbivore class correctly extends Animal and implements the hide method, setting the hidden property to true. This functionality is crucial for the herbivore's survival mechanism.

  • Carnivore Class: The Carnivore class extends Animal and the bite method is implemented correctly. It checks if the target is an instance of Herbivore, is not hidden, and is alive before reducing its health. This ensures that the carnivore's actions are logical and effective.

  • Use of Filter Method: The die method efficiently uses the filter method to remove dead animals from the Animal.alive array, which is both efficient and meets the performance guidelines.

There are no critical issues found, and your code is ready to proceed. However, always ensure to review any comments for potential improvements and learning opportunities. Keep up the great work and continue refining your skills! 🚀

✨ 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