Implement animal class hierarchy - #4468
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
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
|
@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
left a comment
There was a problem hiding this comment.
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! ✨
No description provided.