Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 43d2fb9

Browse files
Jashele TJashele T
Jashele T
authored and
Jashele T
committed
refactored character stats
1 parent 4c3363c commit 43d2fb9

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

‎assignments/prototype-refactor.js‎

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Prototype Refactor
3636
// };
3737

3838

39-
// Object Refactored:
39+
// GameObject Object Refactored:
4040

4141
class GameObject {
4242
constructor(GameObj){
@@ -56,36 +56,36 @@ Prototype Refactor
5656
}
5757

5858

59-
60-
61-
62-
6359
// === CharacterStats ===
60+
// function CharacterStats(charAttrs) {
61+
// GameObject.call(this, charAttrs);
62+
// this.healthPoints = charAttrs.healthPoints;
63+
// };
64+
65+
66+
// CharacterStats Refactored:
67+
68+
class CharacterStats extends GameObject {
69+
constructor(charAttrs){
70+
super(GameObj);
71+
this.healthPoints = charAttrs.healthPoints;
72+
}
6473

6574

66-
function CharacterStats(charAttrs) {
67-
GameObject.call(this, charAttrs);
68-
this.healthPoints = charAttrs.healthPoints;
69-
};
70-
71-
CharacterStats.prototype = Object.create(GameObject.prototype);
75+
// CharacterStats.prototype = Object.create(GameObject.prototype);
7276

73-
CharacterStats.prototype.takeDamage = function () {
77+
// CharacterStats.prototype.takeDamage = function () {
78+
// return `${this.name} took damage`;
79+
// }
80+
81+
82+
83+
// CharacterStats Prototype Refactored:
84+
85+
takeDamage(){
7486
return `${this.name} took damage`;
7587
}
76-
77-
// function CharacterStats(CharStats) {
78-
// CharacterStats.prototype = Object.create(GameObject.prototype);
79-
// this.healthPoints = CharStats.healthPoints;
80-
81-
82-
83-
// // should inherit destroy() from GameObject's prototype
84-
// };
85-
86-
// CharacterStats.prototype.takeDamage = function() {
87-
// return `${this.name} took damage.`; // prototype method -> returns the string '<object name> took damage.'
88-
// }
88+
}
8989

9090

9191

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /