Skip to content

Instantly share code, notes, and snippets.

@chriskuruc
Forked from danvideo/bottlesofbeer.rb
Created October 31, 2013 04:59
Show Gist options
  • Save chriskuruc/7244582 to your computer and use it in GitHub Desktop.
Save chriskuruc/7244582 to your computer and use it in GitHub Desktop.
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
end
bottle = BottlesOfBeer.new
bottle.count_off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment