Skip to content

Instantly share code, notes, and snippets.

@javierg
Last active December 12, 2015 08:08
Show Gist options
  • Save javierg/4741870 to your computer and use it in GitHub Desktop.
Save javierg/4741870 to your computer and use it in GitHub Desktop.
Fortuna por moneda stateless
class FortuneTellerMachine
def initialize
@coins = 0
end
def start
puts "Hola ¿Quiéres saber tu fortuna?"
@coins += 1
if @coins == 1
puts "necesito otra moneda, yo quiero moneda."
elsif @coins == 2
puts fortune.shuffle.first
@coins = 0
else
"fortuna por moneda, yo quiero yo quiero moneda"
end
end
def fortune
[
"You only need look to your own reflection for inspiration. Because you are Beautiful!",
"Rivers need springs.",
"Good news from afar may bring you a welcome visitor.",
"When all else seems to fail, smile for today and just love someone.",
"When you look down, all you see is dirt, so keep looking up.",
]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment