Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions assignments/prototypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,34 @@
* destroy() // prototype method that returns: `${this.name} was removed from the game.`
*/

const GameObject(createdAt, name, dimensions, destroy()) {
this.createdAt = createdAt;
this.name = name;
this.dimensions = dimensions;
this.destroy = destroy();

const CharacterStats(healthPoints, takeDamage()) {
this.healthPoints = healthPoints;
this.takeDamage = takeDamage();

const Humanoid(team, weapons, language, greet()) {
this.team = team;
this.weapons = weapons;
this.language = language;
this.greet = greet();
}
}
}

/*
=== CharacterStats ===
* healthPoints
* takeDamage() // prototype method -> returns the string '<object name> took damage.'
* should inherit destroy() from GameObject's prototype
*/



/*
=== Humanoid (Having an appearance or character resembling that of a human.) ===
* team
Expand All @@ -32,6 +53,8 @@
* should inherit destroy() from GameObject through CharacterStats
* should inherit takeDamage() from CharacterStats
*/



/*
* Inheritance chain: GameObject -> CharacterStats -> Humanoid
Expand Down
8 changes: 4 additions & 4 deletions assignments/this.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* The for principles of "this";
* in your own words. explain the four principle for the "this" keyword below.
*
* 1.
* 2.
* 3.
* 4.
* 1. Is the function called by new?
* 2. Is the function called by call(), apply(), or bind()?
* 3. Is the function called as a method, ie: obj.func()?
* 4. Is the function called in the global scope?
*
* write out a code example of each explanation above
*/
Expand Down