You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Object oriented design is commonly used in video games. For this part of the assignment you will be implementing several constructor functions with their correct inheritance heirarchy.
2
+
Object oriented design is commonly used in video games. For this part of the assignment you will be implementing several constructor functions with their correct inheritance hierarchy.
3
3
4
4
In this file you will be creating three constructor functions: GameObject, CharacterStats, Humanoid.
5
5
6
6
At the bottom of this file are 3 objects that all end up inheriting from Humanoid. Use the objects at the bottom of the page to test your constructor functions.
7
7
8
-
Each constructor function has unique properites and methods that are defined in their block comments below:
8
+
Each constructor function has unique properties and methods that are defined in their block comments below:
9
9
*/
10
10
11
11
/*
12
12
=== GameObject ===
13
13
* createdAt
14
-
* dimensions
14
+
* dimensions (These represent the character's size in the video game)
15
15
* destroy() // prototype method -> returns the string: 'Object was removed from the game.'
16
16
*/
17
17
18
18
/*
19
19
=== CharacterStats ===
20
-
* hp
20
+
* healthPoints
21
21
* name
22
22
* takeDamage() // prototype method -> returns the string '<object name> took damage.'
23
23
* should inherit destroy() from GameObject's prototype
24
24
*/
25
25
26
26
/*
27
-
=== Humanoid ===
28
-
* faction
27
+
=== Humanoid (Having an appearance or character resembling that of a human.) ===
28
+
* team
29
29
* weapons
30
30
* language
31
31
* greet() // prototype method -> returns the string '<object name> offers a greeting in <object language>.'
@@ -39,7 +39,7 @@
39
39
* Instances of CharacterStats should have all of the same properties as GameObject.
40
40
*/
41
41
42
-
// Test you work by uncommenting these 3 objects and the list of console logs below:
42
+
// Test you work by un-commenting these 3 objects and the list of console logs below:
console.log(swordsman.faction); // The Round Table
99
+
console.log(swordsman.team); // The Round Table
100
100
console.log(mage.weapons); // Staff of Shamalama
101
101
console.log(archer.language); // Elvish
102
102
console.log(archer.greet()); // Lilith offers a greeting in Elvish.
@@ -105,6 +105,6 @@
105
105
*/
106
106
107
107
// Stretch task:
108
-
// * Create Villian and Hero constructor functions that inherit from the Humanoid constructor function.
109
-
// * Give the Hero and Villians different methods that could be used to remove health points from objects which could result in destruction if health gets to 0 or drops below 0;
110
-
// * Create two new objects, one a villian and one a hero and fight it out with methods!
108
+
// * Create Villain and Hero constructor functions that inherit from the Humanoid constructor function.
109
+
// * Give the Hero and Villains different methods that could be used to remove health points from objects which could result in destruction if health gets to 0 or drops below 0;
110
+
// * Create two new objects, one a villain and one a hero and fight it out with methods!
0 commit comments