Skip to content

Implement animal class hierarchy - #4468

Open
luanstipp2018-arch wants to merge 2 commits into
mate-academy:masterfrom
luanstipp2018-arch:master
Open

Implement animal class hierarchy#4468
luanstipp2018-arch wants to merge 2 commits into
mate-academy:masterfrom
luanstipp2018-arch:master

Conversation

@luanstipp2018-arch

Copy link
Copy Markdown

No description provided.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

Your implementation correctly fulfills all functional requirements, and the code works as expected. However, it violates checklist item #1, which explicitly requires using the filter method instead of indexOf + splice for removing dead animals from Animal.alive. In the bite method (lines 34-38), replace the current indexOf + splice logic with a filter operation. After the health check and decrement, update Animal.alive to keep only animals with health greater than 0: javascript // Instead of indexOf + splice, use filter: Animal.alive = Animal.alive.filter(aliveAnimal => aliveAnimal.health > 0); This change should be placed after the health decrement logic and will ensure only living animals remain in the static array. The rest of your implementation is solid and shows good understanding of class hierarchies, static properties, and method interactions.


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

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread src/herbivoresAndCarnivores.js Outdated
@luanstipp2018-arch

Copy link
Copy Markdown
Author

@mateacademy-ai-mentor The requested change has been applied. Animal.alive now uses filter, and all 14 tests pass. Please review again.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

Your implementation is correct and complete. All functional requirements are met: the class hierarchy is properly structured with Herbivore and Carnivore extending Animal, the hide method correctly sets hidden to true, the bite method properly checks for Herbivore instances and hidden status, and dead animals are removed from the static Animal.alive array using filter as required. All 14 tests pass successfully, and both checklist items are satisfied. Great work!


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

Footnotes

  1. Rate AI review example

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