Skip to content

Solution - #4534

Open
232567 wants to merge 2 commits into
mate-academy:masterfrom
232567:develop
Open

Solution#4534
232567 wants to merge 2 commits into
mate-academy:masterfrom
232567:develop

Conversation

@232567

@232567 232567 commented Aug 31, 2026

Copy link
Copy Markdown

Gostei bastante desta atividade! Ela me ajudou a entender melhor classes, herança, extends, super(), métodos estáticos e instanceof na prática. Também foi muito útil para compreender como as classes podem interagir entre si. Obrigado pela aula e pelas explicações!

@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

I am requesting changes because there’s a [CHECKLIST ITEM #1] violation that must be addressed. Functionally, your implementation is solid: Animal has correct defaults, Herbivore.hide and Carnivore.bite behave as specified, and dead animals are removed from Animal.alive. However, on lines 34–38 you remove a dead animal using the indexOf + splice pattern, which the checklist explicitly disallows.

Critical issue to fix:

  • Lines 34–38: Replace the indexOf/splice removal with a non-mutating filter to rebuild Animal.alive without the dead instance (e.g., Animal.alive = Animal.alive.filter(a => a !== deadAnimal)). This aligns with the required approach and avoids in-place mutations.

Minor note:

  • Keeping operations immutable improves clarity and reduces side effects.

Once you switch to filter for removing dead animals, this will be good to go. Nice work on meeting the functional requirements overall!


✨ 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
Comment on lines +33 to +38

if (animal.health <= 0) {
const index = Animal.alive.indexOf(animal);

if (index !== -1) {
Animal.alive.splice(index, 1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Checklist item #1 violation: This uses indexOf + splice pattern. Prefer using filter instead to create a new array without the dead animal.

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

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

@232567

232567 commented Aug 31, 2026

Copy link
Copy Markdown
Author

Obrigado pelo feedback! Corrigi a remoção dos animais mortos, substituindo indexOf e splice por filter, conforme solicitado no checklist. Rodei novamente os testes e todos os 14 testes passaram, assim como o ESLint. A alteração já foi enviada para o Pull Request.

@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 approved and meets all requirements. The Animal class correctly implements health (default 100) and name properties, Herbivore properly extends Animal with the hide method that sets hidden to true, and Carnivore's bite method correctly reduces herbivore health by 50 while checking for Herbivore instances and hidden status. The [CHECKLIST #1] requirement to use filter instead of indexOf/splice for removal is satisfied, and [CHECKLIST #2] to set hidden to true (not toggle) is also implemented correctly. All dead animals are properly removed from the static Animal.alive array. Well done!


✨ 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