1515 * destroy() // prototype method -> returns the string: 'Object was removed from the game.'
1616*/
1717
18- GameObject . prototype = Object . create ( Humanoid . prototype ) ;
18+
1919function GameObject ( gameobjectbutes ) {
2020 this . createdAt = gameobjectbutes . createdAt ;
2121 this . dimensions = gameobjectbutes . dimensions ;
22- //CharacterStats.call(this, gameobjectbutes);
23- Humanoid . call ( this , gameobjectbutes ) ;
2422}
2523
2624GameObject . prototype . destroy = function ( ) {
@@ -36,14 +34,15 @@ GameObject.prototype.destroy = function(){
3634 * should inherit destroy() from GameObject's prototype
3735*/
3836
39- CharacterStats . prototype = Object . create ( Humanoid . prototype ) ;
37+
4038function CharacterStats ( characterbutes ) {
41- //Humanoid.call(this, characterbutes);
4239 GameObject . call ( this , characterbutes ) ;
4340 this . healthPoints = characterbutes . healthPoints ;
4441 this . name = characterbutes . name ;
4542}
4643
44+ CharacterStats . prototype = Object . create ( GameObject . prototype ) ;
45+
4746
4847CharacterStats . prototype . takeDamage = function ( ) {
4948 return `${ this . name } took damage.` ;
@@ -58,13 +57,16 @@ CharacterStats.prototype.takeDamage = function(){
5857 * should inherit destroy() from GameObject through CharacterStats
5958 * should inherit takeDamage() from CharacterStats
6059*/
60+
6161function Humanoid ( attributes ) {
62- // CharacterStats.call(this, attributes);
62+ CharacterStats . call ( this , attributes ) ;
6363 //GameObject.call(this, attributes);
6464 this . team = attributes . team ;
6565 this . weapons = attributes . weapons ;
6666 this . language = attributes . language ;
6767}
68+ Humanoid . prototype = Object . create ( CharacterStats . prototype ) ;
69+
6870Humanoid . prototype . great = function ( ) {
6971 return `${ this . team } says hello in ${ this . language } ` ;
7072 }
@@ -79,7 +81,7 @@ Humanoid.prototype.great = function(){
7981
8082
8183 const mage = new Humanoid ( {
82- createdAt : Date . now ( ) ,
84+ createdAt : new Date ( ) ,
8385 dimensions : {
8486 length : 2 ,
8587 width : 1 ,
@@ -94,10 +96,8 @@ Humanoid.prototype.great = function(){
9496 language : 'Common Tongue' ,
9597 } ) ;
9698
97- console . log ( mage ) ;
98-
9999 const swordsman = new Humanoid ( {
100- createdAt : Date . now ( ) ,
100+ createdAt : new Date ( ) ,
101101 dimensions : {
102102 length : 2 ,
103103 width : 2 ,
@@ -114,7 +114,7 @@ Humanoid.prototype.great = function(){
114114 } ) ;
115115
116116 const archer = new Humanoid ( {
117- createdAt : Date . now ( ) ,
117+ createdAt : new Date ( ) ,
118118 dimensions : {
119119 length : 1 ,
120120 width : 2 ,
@@ -131,16 +131,16 @@ Humanoid.prototype.great = function(){
131131 } ) ;
132132
133133
134- // console.log(mage.createdAt); // Today's date
135- // console.log(archer.dimensions); // { length: 1, width: 2, height: 4 }
136- // console.log(swordsman.healthPoints); // 15
137- // console.log(mage.name); // Bruce
138- // console.log(swordsman.team); // The Round Table
139- // console.log(mage.weapons); // Staff of Shamalama
140- // console.log(archer.language); // Elvish
141- // console.log(archer.great()); // Lilith offers a greeting in Elvish.
142- // console.log(mage.takeDamage()); // Bruce took damage.
143- // console.log(swordsman.destroy()); // Sir Mustachio was removed from the game.
134+ console . log ( mage . createdAt ) ; // Today's date
135+ console . log ( archer . dimensions ) ; // { length: 1, width: 2, height: 4 }
136+ console . log ( swordsman . healthPoints ) ; // 15
137+ console . log ( mage . name ) ; // Bruce
138+ console . log ( swordsman . team ) ; // The Round Table
139+ console . log ( mage . weapons ) ; // Staff of Shamalama
140+ console . log ( archer . language ) ; // Elvish
141+ console . log ( archer . great ( ) ) ; // Lilith offers a greeting in Elvish.
142+ console . log ( mage . takeDamage ( ) ) ; // Bruce took damage.
143+ console . log ( swordsman . destroy ( ) ) ; // Sir Mustachio was removed from the game.
144144
145145
146146 // Stretch task:
0 commit comments