This is my brain on reason.

99 Bottles of Beer on the Wall – Ruby Code

Written by Chantal in category 
May 17, 2008
Here is my (very simple) version of 99 Bottles of Beer on the Wall in Ruby. I the only fancy thing I am doing is “while”. I don’t like the fact that the song is duplicated to handle one bottle, so I will eventually change that. I have a couple of ideas, but I am not sure which I want to use.


#99 Bottles of Beer on the Wall

bottles = 99

while bottles != 1
puts “#{bottles} bottles of beer on the wall, #{bottles} bottles of beer.”
puts “Take one down and pass it around, #{bottles -1} bottles of beer on the wall.”
puts ”
bottles = bottles – 1
end

# Do this when there is one bottle left so we don’t have “one bottles” of beer
puts “#{bottles} bottle of beer on the wall, #{bottles} bottle of beer.”
puts “Take one down and pass it around, no bottles of beer on the wall.”
puts ”
puts ‘Time to buy some more beer!’