Guest User

final.rb

a guest
Jun 1st, 2016
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. #Final Project by Kevin Vieira#
  2.  
  3. monitor = rand(10) #Random integers
  4. keyboard = rand(15)
  5.  
  6. puts 'Sign in mode beginning'
  7.  
  8. puts '-'*30
  9.  
  10. username = [["admin"], ["guest"]] #Array
  11.  
  12. puts "Are you an admin or a guest" #Multidimensional Array
  13. input = gets.chomp
  14.  
  15. if input == username[0][0] or input == username[1][0] #What gets you it.
  16. puts "Now to the password."
  17. else
  18. puts "Wrong. Please Leave"
  19. abort #Exits
  20. end
  21.  
  22. password = [["football"],["soccer"]] #Another Array
  23.  
  24. puts "Enter password."
  25. userinput = gets.chomp
  26.  
  27. if userinput == password[0][0] or userinput == password[1][0]
  28. puts "Your in. You can enter:"
  29. else
  30. puts "Denied. Please Leave."
  31. abort
  32. end
  33.  
  34. puts '-'*30
  35.  
  36. puts """
  37. Welcome to the program!
  38. """
  39.  
  40. puts """
  41. Let's do a check to see if you are able to access this.
  42. """
  43. puts '-'*30
  44.  
  45. def check(number, tool) #tool is used as a place holder
  46. if number > 1 #arbitrary number to continue
  47. puts "It works. Congrats!" #Now you can move on.
  48. else
  49. puts "#{tool} isn't working. Goodbye."
  50. abort #Leaves
  51. end
  52. end
  53.  
  54. puts monitor, "monitor ^" #Prints the number.
  55. puts keyboard, "keyboard ^"
  56.  
  57. check(monitor,"Monitor" ) #Calls to the function.
  58. check(keyboard,"Keyboard")
  59.  
  60. puts '-'*30
Add Comment
Please, Sign In to add comment