November 2008
Intermediate to advanced
208 pages
4h 32m
English
Hangman is another fun word game! Most people know how to play hangman. If a user doesn't know how to play, the rules are simple to explain. A word is randomly chosen and only the number of characters is known—sort of like Wheel of Fortune. The user has six tries to figure out the word, or else the man is hanged and game lost.
unless ARGV[0] and File.exists?(ARGV[0])
puts "\n\nUsage is hangman.rb <word.file>\n\n"
exit
end
words = File.readlines(ARGV[0])
mystery_word = words[rand(words.size)].chomp
solution = Array.new(mystery_word.length, "-")
guessed = []
steps = 6
while steps > 0
puts <<EOM \n\n\nYou have #{steps} ...Read now
Unlock full access