Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.83 KB | None | 0 0
  1. answer = ""
  2.  
  3. loop do
  4.  
  5.     puts ("\n"*25) #added the closing parenthesis
  6.  
  7.     puts "How much do you like Star Wars?\n\n"
  8.  
  9.     puts "A: I love it so much!"
  10.  
  11.     puts "B: It's alright"
  12.  
  13.     puts "C: I don't like it"
  14.  
  15.     puts "D: I live under a rock and don't know what that is"
  16.  
  17.     print "?: "
  18.  
  19.     answer = STDIN.gets
  20.  
  21.     answer.chop!
  22.  
  23.     if answer !~ /[abcd]/i
  24.  
  25.         puts "Invaild answer! Press enter to try again..."
  26.  
  27.         STDIN.gets
  28.  
  29.     else
  30.  
  31.         break
  32.  
  33.     end
  34.  
  35. end
  36.  
  37. puts ("\n"*25)
  38.  
  39. case answer
  40.  
  41. when /A|a/
  42.  
  43.     puts "That's awesome! I love it, too!"
  44.  
  45. when /B|b/ #added the closing slash '/'
  46.  
  47.     puts "Well maybe you should watch it again."
  48.  
  49. when /C|c/
  50.  
  51.     puts "Everyone is entitled to their own opinion..."
  52.  
  53. else
  54.  
  55.     puts "Stop what you're doing and go watch it now!"
  56.  
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement