Skip to content

Instantly share code, notes, and snippets.

@vidjuheffex
Created July 17, 2017 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vidjuheffex/decaffa99d08c59579cff312ae464b5e to your computer and use it in GitHub Desktop.
Save vidjuheffex/decaffa99d08c59579cff312ae464b5e to your computer and use it in GitHub Desktop.
Modifications to main.js to have tests pass
//###################################################################
// __
// ____/ /___ ____ ______
// / __ / __ \/ __ `/ ___/
// / /_/ / /_/ / /_/ (__ )
// \__,_/\____/\__, /____/
// /____/
// Dog Constructor & Prototype
var Dog = {
create(name, color, status, hungry, owner){
var dog = Object.create(Dog.prototype);
dog.name = name;
dog.color = color;
dog.status = status;
dog.hungry = hungry;
dog.owner = owner;
return dog;
},
prototype: {
}
};
var Human = {
create(name, isCool){
var human = Object.create(Human.prototype);
human.name = name;
human.cool = isCool;
return human;
},
prototype: {
pet(dog){
dog.status = "happy";
},
feed(dog){
dog.hungry = false;
}
}
}
// Instances of Dog
// Needed: sadie, moonshine, atticus
// Instances of Human
// Needed: mason, julia
var sadie= Dog.create("sadie", "black", "normal", false, undefined);
var moonshine = Dog.create("moonshine", "brown", "normal", true, undefined);
var atticus = Dog.create("moonshine", "brown", "normal", true, undefined);
var mason=Human.create("mason", false);
var julia = Human.create("julia", true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment