Advertisement
jessicakennedy1028

Beer Song!

Sep 14th, 2018
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.72 KB | None | 0 0
  1. puts; puts "   It's beer song time!"; puts
  2.  
  3. @count = 99
  4. @container = "bottle"
  5. @getDrunkBy = @count - 10
  6.  
  7. def bottles(n, container)
  8.   n == 1 ? "#{n} #{container}" : "#{n} #{container}s"
  9. end
  10.  
  11. def getDrunk(str, n, by)
  12.   by <= n ? str : str.split(' ').shuffle.join(' ').capitalize
  13. end
  14.  
  15.  
  16. @count.downto(1) {
  17.   puts <<BEERSONG
  18. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  19.    #{bottles(@count, @container)} of beer on the wall
  20.    #{bottles(@count, @container)} of beer
  21.    #{getDrunk('Take one down pass it around', @count, @getDrunkBy)}
  22.    #{bottles(@count -= 1, @container)} of beer on the wall
  23. BEERSONG
  24. }
  25.  
  26. puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  27. puts; puts "   No more beer on the wall :-("
  28. puts "   And I'm on the floor"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement