Advertisement
Guest User

Untitled

a guest
Nov 7th, 2012
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. def get_questions
  2. puts "What is the file name where the questions are located, including extension ?"
  3. questions_file = gets.chomp
  4. file = File.new( questions_file , 'r')
  5. unless file.exists? do
  6. puts "That is not a valid file!"
  7. break
  8. return
  9. end
  10. end
  11.  
  12. def question(str, hash)
  13. answers = 1
  14. puts str
  15. hash.each do | rightwrong, string |
  16. if rightwrong = 'true'
  17. answers = string
  18. else
  19. continue
  20. end
  21. end
  22. return answers
  23. end
  24.  
  25. def get_answer
  26. puts "Please enter your choice: "
  27. choice = gets.chomp
  28. if choice == nil or !choice.respond_to?('to_i')
  29. puts "You have entered an incorrect choice, please try again."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement