Skip to content

Instantly share code, notes, and snippets.

@abrahamsangha
Created August 13, 2013 16:19
Show Gist options
  • Save abrahamsangha/6222870 to your computer and use it in GitHub Desktop.
Save abrahamsangha/6222870 to your computer and use it in GitHub Desktop.
function Cookie(type, bakeTime) {
this.type = type,
this.bakeTime = bakeTime,
this.timeBaked = 0,
this.status = "Raw"
};
Cookie.prototype = {
updateStatus: function(){
if (this.timeBaked < this.bakeTime) {
this.status = "Still Gooey"
}
else if (this.timeBaked === this.bakeTime) {
this.status = "Ready"
}
else {
this.status = "Burnt up"
}
}
};
var Oven = {
init: function(){
this.cookies = []
},
addCookies: function(cookie){
this.cookies.push(cookie);
},
bake: function(){
this.cookies.forEach(
function(cookie){
cookie.timeBaked++;
cookie.updateStatus();
}
)}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment