Skip to content

Instantly share code, notes, and snippets.

@mariyadiminsky
Created June 27, 2016 01:13
Show Gist options
  • Save mariyadiminsky/9a71431551a2e69c17792608ff67829f to your computer and use it in GitHub Desktop.
Save mariyadiminsky/9a71431551a2e69c17792608ff67829f to your computer and use it in GitHub Desktop.
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