Last active
January 7, 2020 03:00
-
-
Save danvideo/7244313 to your computer and use it in GitHub Desktop.
X Bottles of Beer on the Wall
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 count_off | |
puts "How many bottles of beer have you got? " | |
numbers = gets.chomp.to_i | |
numbers.downto(1) 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 | |
end | |
bottle = BottlesOfBeer.new | |
bottle.count_off | |
end |
👍
Love it!
I'm at work right now, so I'll post later. I added an 'elsif' so the '1 bottle of beer line' so now reads: "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". I also added if number.zero? on line 14.
My try! https://gist.github.com/StevenNunez/7253815 The first one is more readable...
ha - great. don't have ruby on my office computer so trying to map it out in my head... definitely need to take a deeper look later
The short one was a bit obtuse on purpose. The word you want to look for is lambda
Late to the party but here's my attempt! https://gist.github.com/christianmendoza/7293928
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey guys - I also forked and added stuff. I made a
pluralize?
method that figures out if bottle should be "bottle" or "bottles" so the string doesn't have to be written out again for 1 bottle of beer. https://gist.github.com/daniellermcd/7252130