Guest User

wetsBed

a guest
Aug 28th, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.91 KB | None | 0 0
  1. def ask question
  2.   goodAnswer = false
  3.   while (not goodAnswer)
  4.     puts question
  5.     reply = gets.chomp.downcase
  6.    
  7.     if (reply == 'yes' or reply == 'no')
  8.       goodAnswer = true
  9.       if reply == 'yes'
  10.         answer = true
  11.       else
  12.         answer = false
  13.       end
  14.     else
  15.       puts 'Please answer "yes" or "no".'
  16.     end
  17.   end
  18.  
  19.   answer  #  This is what we return (true or false).
  20. end
  21.  
  22. puts 'Hello, and thank you for...'
  23. puts
  24.  
  25. ask 'Do you like eating tacos?'      #  We ignore this return value.
  26. ask 'Do you like eating burritos?'
  27. wetsBed = ask 'Do you wet the bed?'  #  We save this return value.
  28. ask 'Do you like eating chimichangas?'
  29. ask 'Do you like eating sopapillas?'
  30. ask 'Do you like eating tamales?'
  31. puts 'Just a few more questions...'
  32. ask 'Do you like drinking horchata?'
  33. ask 'Do you like eating flautas?'
  34.  
  35. puts
  36. puts 'DEBRIEFING:'
  37. puts 'Thank you for...'
  38. puts
  39. puts wetsBed
Advertisement
Add Comment
Please, Sign In to add comment