Skip to content

Instantly share code, notes, and snippets.

@jonjaques
Created January 18, 2016 22: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 jonjaques/c945a55ad2ed4d3e34fe to your computer and use it in GitHub Desktop.
Save jonjaques/c945a55ad2ed4d3e34fe to your computer and use it in GitHub Desktop.
class Coffee {
constructor() {
this.refill()
}
get empty() {
return this.level === 0;
}
refill() {
console.log('fresh pots!')
this.level = 100;
}
drink() {
Math.random() > 0.1 ? console.log('gulp, gulp, gulp') : console.log('hickup..')
this.level = 0
}
}
var coffee = new Coffee()
setInterval(function() {
if (coffee.empty) {
coffee.refill()
} else {
coffee.drink()
}
}, 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment