Created
October 21, 2013 14:00
-
-
Save christiansmith/7084333 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sip = 1 | |
slurp = 2 | |
gulp = 3 | |
class EarlyRiser | |
constructor: (@config) -> | |
@caffeinated = false | |
@cupsRequired = @config.cupsRequired | |
@cupsConsumed = | |
@cupLevel = 0 | |
console.log "I need #{@cupsRequired} cups of coffee to get started" | |
getCoffee: => | |
@cupLevel = 10 | |
if @cupsConsumed is 0 | |
console.log "The first cup is always the best" | |
else | |
console.log "This is cup number #{@cupsConsumed}" | |
drinkCoffee: (amount) => | |
@getCoffee() unless @cupLevel > 0 | |
if amount is gulp and @cupLevel > 5 | |
console.log "Be careful, this coffee is hot!" | |
@cupLevel -= amount | |
if @cupLevel > 0 | |
console.log "#{@cupLevel} sips remaining in this cup" | |
@drinkCoffee(Math.floor(Math.random()*4)) | |
else if @cupsConsumed < @cupsRequired | |
console.log "The cup is 0% full. Time to get another cup" | |
@cupsConsumed += 1 | |
@drinkCoffee(Math.floor(Math.random()*4)) | |
else | |
@caffeinated = true | |
console.log "#{Math.floor @cupsConsumed} cups of coffee consumed" | |
console.log "Ready to write some code" | |
me = new EarlyRiser cupsRequired: 3 | |
me.drinkCoffee(sip) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment