Skip to content

Instantly share code, notes, and snippets.

class BottlesOfBeer
def count_off
puts "How many bottles of beer have you got? "
bottles = gets.chomp.to_i
bottles.downto(2) do |number|
puts "#{number} bottles of beer on the wall, #{number} bottles of beer! Take one down, pass it around, #{number-1} bottles of beer on the wall!"
end
puts "1 bottle of beer on the wall, 1 bottle of beer! Take one down, pass it around, No more bottles of beer on the wall!"
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!"
end