Advertisement
Guest User

Ruby Program not working

a guest
Jun 22nd, 2014
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.58 KB | None | 0 0
  1. class String
  2. def black;          "\033[30m#{self}\033[0m" end
  3. def red;            "\033[31m#{self}\033[0m" end
  4. def green;          "\033[32m#{self}\033[0m" end
  5. def brown;          "\033[33m#{self}\033[0m" end
  6. def blue;           "\033[34m#{self}\033[0m" end
  7. def magenta;        "\033[35m#{self}\033[0m" end
  8. def cyan;           "\033[36m#{self}\033[0m" end
  9. def gray;           "\033[37m#{self}\033[0m" end
  10. def bg_black;       "\033[40m#{self}\033[0m" end
  11. def bg_red;         "\033[41m#{self}\033[0m" end
  12. def bg_green;       "\033[42m#{self}\033[0m" end
  13. def bg_brown;       "\033[43m#{self}\033[0m" end
  14. def bg_blue;        "\033[44m#{self}\033[0m" end
  15. def bg_magenta;     "\033[45m#{self}\033[0m" end
  16. def bg_cyan;        "\033[46m#{self}\033[0m" end
  17. def bg_gray;        "\033[47m#{self}\033[0m" end
  18. def bold;           "\033[1m#{self}\033[22m" end
  19. def reverse_color;  "\033[7m#{self}\033[27m" end
  20. end
  21. puts "We now need to ask you some questions to prove that you are a human.".green.bold.bg_cyan
  22. stop = false
  23. tries = 0
  24. while stop == false
  25.     win = 5
  26.     puts "Which of the following is NOT a real country?".green.bold
  27.     puts "  a\) Sudan".blue
  28.     puts "  b\) Canada".blue
  29.     puts "  c\) The Yukon".blue
  30.     puts "  d\) Luxembourg".blue
  31.     questionOne = gets.to_s
  32.     if questionOne != "c"
  33.         win -= 1
  34.     end
  35.     puts "Which of the following is traditionally made in Russia?".green.bold
  36.     puts "  a\) Vodka".blue
  37.     puts "  b\) Ale".blue
  38.     puts "  c\) Wine".blue
  39.     puts "  d\) Whiskey".blue
  40.     questionTwo = gets.to_s
  41.     if questionTwo != "a"
  42.         win -= 1
  43.     end
  44.     puts "What is the square root of 49?".green.bold
  45.     puts "  a\) 3.14".blue
  46.     puts "  b\) 16".blue
  47.     puts "  c\) Impossible!".blue
  48.     puts "  d\) 7".blue
  49.     questionThree = gets.to_s
  50.     if questionThree != "d"
  51.         win -= 1
  52.     end
  53.     puts "What is the scientific name of humans?".green.bold
  54.     puts "  a\) Humanus Intelligentio".blue
  55.     puts "  b\) Primanus Homo".blue
  56.     puts "  c\) Homo Sapiens".blue
  57.     puts "  d\) Primanus Brilliante".blue
  58.     questionFour = gets.to_s
  59.     if questionFour != "c"
  60.         win -= 1
  61.     end
  62.     puts "What is the terminated Skylanders mmo called?".green.bold
  63.     puts "  a\) Skylanders: Spyro's Adventure".blue
  64.     puts "  b\) Skylanders: Universe".blue
  65.     puts "  c\) Skylanders: Battlegrounds".blue
  66.     puts "  d\) Skylanders: Lightning Rod versus The Cyclops Queen".blue
  67.     questionFive = gets.to_s
  68.     if questionFive != "b"
  69.         win -= 1
  70.     end
  71.     if win >= 5
  72.         win = 5
  73.     end
  74.     if win > 3
  75.         haveWon = true
  76.         puts "You've Won! Welcome to Sky Tech".green
  77.         stop = true
  78.     else
  79.         tries += 1
  80.         if tries == 10
  81.             stop = true
  82.             puts "You have failed!".red
  83.             haveWon = false
  84.         end
  85.     end
  86. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement