Advertisement
thathamr

Bools

Apr 28th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. ### Welcome to the Boolean Project. by Ram Thatham (C)
  2. computerstatus = 0
  3.  
  4. puts "Enter your username:" #username- users choice
  5. username = gets.chomp()
  6. puts "Welcome #{username}"
  7.  
  8.  
  9. puts "Please enter your authentication code:"
  10. password = gets.to_i
  11. puts password
  12. passcode = [000,007,101,001]#array of accepted passwords
  13.  
  14.  
  15. if password = passcode[0..4] #range is for elements in array
  16. puts "Wow you are in!"
  17. puts "NUMBERS INTIATIVE SPOOLING UP"
  18. computerstatus = 1
  19. elsif password != passcode[0..4]
  20. puts "Unfortunatley, you only get guest status."
  21. puts "NUMBERS INTIATIVE SPOOLING UP"
  22. computerstatus = 2
  23. end
  24.  
  25.  
  26.  
  27. #welcome to the program !
  28.  
  29.  
  30. if computerstatus == 1
  31. require "./admin.rb" ##calls up this file
  32. end
  33.  
  34. if computerstatus == 2
  35. require "./guest.rb" ##calls up this file
  36. end
  37.  
  38.  
  39.  
  40. puts "Hi, I'm thinking of a number between 1 and 50 in 5 tries!"
  41.  
  42.  
  43. count = 0
  44. number = rand(50) #range 1-50
  45.  
  46. while count <= 5 #From Python Number Guesser
  47. puts ''
  48. count = count+1
  49. guess = gets.to_i #guess
  50. if guess == number #if guess is the range number
  51. puts "BOMB HAS BEEN DEFUSED! Thanks for playing"
  52. abort #ends the program
  53. end
  54. if number < guess #too high
  55. puts "Number is too darn high" # Too High or Too Low - Ram
  56. end
  57. if number > guess #too low
  58. puts "Low bro" #Ram
  59. end
  60. if count == 5 #Ram
  61. puts "THE BOMB HAS GONE OFF , YIKES !" #This was designed to limit guesses on numbers - Ram
  62. abort #ends program
  63. end
  64. end
  65.  
  66.  
  67.  
  68. puts "Hi, I'm thinking of a number between 1 to 50 in 10 tries!"
  69.  
  70.  
  71. count = 0
  72. number = rand(50) #range 1-50
  73.  
  74. while count <= 10 #While loop from Python Number Guessing
  75. puts ''
  76. count = count+1 #Count to ensure tries are in order
  77. guess = gets.to_i #guess
  78. if guess == number #if guess is the range number
  79. puts "Winner Winner Chicken Dinner! Thanks for playing"
  80. abort #ends the program
  81. end
  82. if number < guess #too high
  83. puts "Number is too darn high" # Too High or Too Low - Ram
  84. end
  85. if number > guess #too low
  86. puts "Low bro" #Ram
  87. end
  88. if count == 10 #Ram
  89. puts "10 Tries are up, Sorry!" #This was designed to limit guesses on numbers - Ram
  90. abort
  91. end
  92. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement