Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beer_Song #37

Open
wants to merge 1 commit into
base: strain
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions beer_song.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
class BeerSong
def verse(num)
if num == 1
return "#{num} bottle of beer on the wall, #{num} bottle of beer.\n" \
"Take it down and pass it around, no more bottles of beer on the wall.\n"
elsif num == 0
return "No more bottles of beer on the wall, no more bottles of beer.\n" \
"Go to the store and buy some more, 99 bottles of beer on the wall.\n"
elsif num == 2
return "#{num} bottles of beer on the wall, #{num} bottles of beer.\n" \
"Take one down and pass it around, #{num - 1} bottle of beer on the wall.\n"
else
return "#{num} bottles of beer on the wall, #{num} bottles of beer.\n" \
"Take one down and pass it around, #{num - 1} bottles of beer on the wall.\n"
end
end
def verses(start_num, end_num)
result = ""
(start_num.downto(end_num)).each do |i|
if i > end_num
result << verse(i) + "\n"
else
result << verse(i)
end
end
result
end
def lyrics
verses(99,0)
end
end
# p BeerSong.new.verses(99, 97)
module BookKeeping
VERSION = 2
end