metasoarous and many others are using Hackety Hack to learn how to code.

Hackety Hack is a free program for Windows, Mac OS X and Linux that can teach you how to make games, applications and more and share those programs with your friends. You can ask other budding programmers questions and follow them to see what code they're working on through the Hackety Hack website.

Sign up Learn More

bottlesofbeer by metasoarous

# 100 bottles of beer on the wall
# root beer, naturally...

# This sings a line of the song
def sing_line(verse_number, line_number)
  case line_number
  when 1
    puts "#{verse_number} bottles of beer on the wall"
  when 2
    puts "#{verse_number} bottles of beer"  
  when 3
    puts "Take one down, pass it around"
  when 4
    puts "#{verse_number - 1} bottles of beer on the wall!"
  end
  # Wait a second so that someone can read the line
  time = Time.now
  time_now = Time.now
  until time_now - time > 1.5  
    time_now = Time.now
    # Twiddle the processor's thumbs while we wait...
  end
end

def sing_verse(verse_number)
  (1..4).each { |line_number| sing_line(verse_number, line_number) }
end

def sing_song(number_of_verses)
  until number_of_verses < 1
    sing_verse(number_of_verses)
    number_of_verses -= 1
  end
end

sing_song(100)