Created
November 1, 2013 18:34
-
-
Save josephdburdick/7269777 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 BottlesOfBeer | |
def pluralize? n | |
if n != 1 | |
"bottles" | |
else | |
"bottle" | |
end | |
end | |
def count_off | |
puts "How many bottles of beer have you got? " | |
bottles = gets.chomp.to_i | |
bottles.downto(0) do |number| | |
if number == 0 | |
puts "No more bottles of beer on the wall, no more bottles of beer! Go to the store and buy some more, #{bottles} bottles of beer on the wall!" | |
else | |
puts "#{number} #{pluralize?(number)} of beer on the wall, #{number} #{pluralize?(number)} of beer! Take one down, pass it around, #{number-1} #{pluralize?(number-1)} of beer on the wall!" | |
end | |
end | |
end | |
end | |
BottlesOfBeer.new.count_off |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment