Skip to content

Instantly share code, notes, and snippets.

@josephdburdick
Created November 1, 2013 18:34
Show Gist options
  • Save josephdburdick/7269777 to your computer and use it in GitHub Desktop.
Save josephdburdick/7269777 to your computer and use it in GitHub Desktop.
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