//Animal Type
var Animal = function(name){
this.name = name;
};
//Four Animal Methods
Animal.prototype.speak = function speak(){
"use strict";
console.log("Hi there my name is " + this.name + ".");
}
Animal.prototype.move = function move(){
"use strict"
console.log(this.name + " is walking around.");
}
Animal.prototype.eating = function eating(){
"use strict"
console.log(this.name + " is busy eating at the moment.");
}
Animal.prototype.drinking = function drinking(){
"use strict"
console.log(this.name + " is thirsty and is drinking water.");
}
//The FarmAnimal type
function FarmAnimal(name, farmtype){
Animal.call(this, name);
this.farmtype = farmtype;
}
FarmAnimal.prototype = Object.create(Animal.prototype);
FarmAnimal.prototype.constructor = FarmAnimal;
//FarmAnimal Methods
FarmAnimal.prototype.speak = function(){
console.log("Hi there my name is " + this.name + " and I am a " + this.farmtype);
}
FarmAnimal.prototype.move = function move(){
console.log(this.name + " the " + this.farmtype + " is walking around.");
}
FarmAnimal.prototype.eating = function eating(){
console.log(this.name + this.farmtype + " is busy eating at the moment.");
}
FarmAnimal.prototype.drinking = function drinking(){
console.log(this.name + " the " + this.farmtype + " is thirsty and is drinking water.");
}
//Special FarmAnimal Method
FarmAnimal.prototype.singing = function singing(){
console.log("Old McDonald had a farm, and on this farm was a " + this.farmtype + " named " + this.name + ".");
}
//The PetAnimal type
function PetAnimal(name, pettype){
Animal.call(this, name);
this.pettype = pettype;
}
PetAnimal.prototype = Object.create(Animal.prototype);
PetAnimal.prototype.constructor = PetAnimal;
//PetAnimal Methods
PetAnimal.prototype.speak = function(){
console.log("Hi there my name is " + this.name + " and I am a " + this.pettype + " and I am a pet.");
}
PetAnimal.prototype.move = function move(){
console.log(this.name + " the " + this.pettype + " is slowly moving away from you.");
}
PetAnimal.prototype.eating = function eating(){
console.log(this.name + this.pettype + " knows it is breakfast time and wants to eat.");
}
PetAnimal.prototype.drinking = function drinking(){
console.log(this.name + " the " + this.pettype + " is thirsty and would like some water.");
}
//Special PetAnimal method
PetAnimal.prototype.thepetstore = function thepetstore(){
console.log("Today\'s special is a " + this.pettype + " named " + this.name + "for only $49.99.");
}