Created
August 26, 2010 23:31
-
-
Save ruanwz/552462 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
class Song | |
def initialize | |
@bottles = 99 | |
end | |
def sing | |
@bottles.downto(0) do |bottle| | |
if bottle > 1 | |
puts "#{bottle} bottles of beer on the wall, #{bottle} bottles of beer." | |
puts "Take one down and pass it around, #{bottle - 1} bottles of beer on the wall.\n" | |
elsif bottle == 1 | |
puts "1 bottle of beer on the wall, 1 bottle of beer." | |
puts "Take one down and pass it around, no more bottles of beer on the wall." | |
elsif bottle == 0 | |
puts "No more bottles of beer on the wall, no more bottles of beer." | |
puts "Go to the store and buy some more, 99 bottles of beer on the wall." | |
end | |
end | |
end | |
end | |
Song.new.sing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment