Skip to content

Commit 08685b4

Browse files
converted Humanoid
1 parent 07563f2 commit 08685b4

1 file changed

Lines changed: 13 additions & 15 deletions

File tree

assignments/prototype-refactor.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,25 @@ class CharacterStats extends GameObject {
3737
}
3838

3939
takeDamage() {
40-
return `${this.name} took damage.`
40+
return `${this.name} took damage.`;
4141
}
4242

4343
}
4444

4545

4646

47-
function Humanoid(attributes) { // (Having an appearance or character resembling that of a human.) ===
48-
CharacterStats.call(this, attributes);
49-
50-
this.team = attributes.team;
51-
this.weapons = attributes.weapons;
52-
this.language = attributes.language;
53-
54-
}
55-
56-
Humanoid.prototype = Object.create(CharacterStats.prototype);
57-
Humanoid.prototype.greet = function() {
58-
return `${this.name} offers a greeting in ${this.language}`
59-
};
60-
47+
class Humanoid extends CharacterStats { // (Having an appearance or character resembling that of a human.) ===
48+
constructor(humanoidAttributes) {
49+
super(humanoidAttributes);
50+
this.team = humanoidAttributes.team;
51+
this.weapons = humanoidAttributes.weapons;
52+
this.language = humanoidAttributes.language;
53+
}
54+
greet() {
55+
return `${this.name} offers a greeting in ${this.language}`;
56+
}
57+
}
58+
6159
function Villain(attributes) {
6260
Humanoid.call(this, attributes);
6361
}

0 commit comments

Comments
 (0)