Skip to content

Commit feae6b4

Browse files
committed
Stephen Fargali
function inheritance issues
1 parent ece742f commit feae6b4

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

‎assignments/prototypes.js‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ GameObject.prototype.destroy = function() {
3232
* should inherit destroy() from GameObject's prototype
3333
*/
3434
function CharacterStats(chrAttributes) {
35-
GameObject.call(this, objAttributes);
36-
GameObject.call(this, destroy());
35+
// CharacterStats.prototype = Object.create(GameObject.prototype)
36+
GameObject.call(this, chrAttributes);
3737
this.hp = chrAttributes.hp;
3838
this.name = chrAttributes.name;
3939
};
4040

4141
CharacterStats.prototype.takeDamage = function() {
4242
`${this.name} took damage.`
43-
GameObject.call(this, destroy());
43+
GameObject.call(destroy());
4444
};
4545
/*
4646
=== Humanoid ===
@@ -52,14 +52,15 @@ CharacterStats.prototype.takeDamage = function() {
5252
* should inherit takeDamage() from CharacterStats
5353
*/
5454
function Humanoid(humAttributes) {
55-
CharacterStats.call(this, chrAttributes);
56-
CharacterStats.call(this, takeDamage());
55+
// Humanoid.prototype = Object.create(CharacterStats.prototype);
56+
CharacterStats.call(this, humAttributes);
57+
GameObject.call(takeDamage());
5758
this.faction = humAttributes.faction;
5859
this.weapons = humAttributes.weapons;
5960
this.language = humAttributes.language;
6061
}
61-
Humanoid.prototype.greet = function() {
62-
return `${this.Humanoid} offers a greeting in ${this.language}.`
62+
Humanoid.prototype.greet = function() {
63+
return `${this.name} offers a greeting in ${this.language}.`
6364
};
6465
/*
6566
* Inheritance chain: Humanoid -> CharacterStats -> GameObject

0 commit comments

Comments
 (0)