Created
February 8, 2013 23:21
-
-
Save javierg/4742784 to your computer and use it in GitHub Desktop.
Revisions
-
javierg revised this gist
Feb 8, 2013 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,6 @@ class FortuneTellerMachine def pending puts REQUEST self.coins += gets.to_i if self.coins > COST give_change -
javierg created this gist
Feb 8, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,62 @@ class FortuneTellerMachine WELCOME = "Hola ¿Quiéres saber tu fortuna?" REQUEST = "Fortuna por monedas, yo quiero yo quiero monedas (2): " CHANGE_BACK = "Here is your change" COST = 2 def initialize clear end def start puts WELCOME pending end def pending puts REQUEST puts self.coins self.coins += gets.to_i if self.coins > COST give_change elsif self.coins == COST finish else pending end end def give_change change = self.coins - COST puts [CHANGE_BACK, change].join("") puts finish end def finish puts fortune.shuffle.first clear end def clear self.coins = 0 end def coins= amount @coins = amount end def coins @coins 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