Created
June 27, 2016 01:13
-
-
Save mariyadiminsky/9a71431551a2e69c17792608ff67829f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bunny { | |
constructor(name, age, favoriteFood){ | |
this.name = name; | |
this.age = age; | |
this.favoriteFood = favoriteFood; | |
} | |
eatFavFood() { | |
console.log(`"Mmmm! That ${this.favoriteFood} was delicious", said ${this.name} the ${this.age} year old bunny.`); | |
}; | |
} | |
class BelgianHare extends Bunny { | |
constructor(favDrink, favoriteFood, name, age) { | |
super(name, age, favoriteFood); | |
this.favDrink = favDrink; | |
} | |
drinkFavDrink() { | |
console.log(`\"Thank you for the ${this.favDrink} and ${this.favoriteFood}!\", said ${this.name} the happy ${this.age} year old Belgian Hare bunny.`) | |
} | |
} | |
let newBelgHare = new BelgianHare('Water', 'Grass', 'Donald', 5); | |
newBelgHare.drinkFavDrink(); | |
// "Thank you for the Water and Grass!", said Donald the happy 5 year old Belgian Hare bunny. | |
newBelgHare.eatFavFood(); | |
// "Mmmm! That Grass was delicious", said Donald the 5 year old bunny. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment