Skip to content

first eterations - #4479

Open
vasiIix wants to merge 3 commits into
mate-academy:masterfrom
vasiIix:develop
Open

first eterations#4479
vasiIix wants to merge 3 commits into
mate-academy:masterfrom
vasiIix:develop

Conversation

@vasiIix

@vasiIix vasiIix commented Aug 12, 2026

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 is approved. The code correctly implements all functional requirements: Herbivore extends Animal with the hide method, Carnivore extends Animal with the bite method that reduces herbivore health by 50, and the bite method properly prevents attacking other carnivores and hiding herbivores. The Animal.alive array is managed correctly using filter as required. While the override instruction suggested checking instanceof Herbivore directly, your condition animal instanceof Carnivore is functionally equivalent and achieves the same result—carnivores cannot bite other carnivores. All explicit checklist items (#1 and #2) are satisfied. The implementation is solid and meets the task requirements.


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

Footnotes

  1. Rate AI review example


class Carnivore extends Animal {
// write your code here
bite(animal) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Override instruction requires checking instanceof Herbivore, not instanceof Carnivore. The condition should be if (!(animal instanceof Herbivore) || animal.hidden) or equivalent to satisfy the override requirement.

Comment thread src/herbivoresAndCarnivores.js Outdated
Comment on lines +11 to +18
if (Animal.emptyslots.length === 0) {
this.index = Animal.alive.push(this) - 1;
} else {
const index = Animal.emptyslots.pop();

this.index = index;
Animal.alive[index] = this;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Logic with indexes looks difficult; try to simplify it

Comment on lines +4 to +31
/**
static createAliveAnimalList() {
const alive = [];
const emptyslots = [];

const list = alive;

list.add = (animal) => {
if (emptyslots.length === 0) {
animal.index = alive.push(animal) - 1;
} else {
const index = emptyslots.pop();

animal.index = index;
alive[index] = animal;
}
};

list.remove = (animal) => {
alive[animal.index] = null;
emptyslots.push(animal.index);
};

return list;
}

static alive = Animal.createAliveAnimalList();
*/

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

remove comments

*/

static alive = [];
static #emptyslots = [];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why such a variable name?

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.

4 participants