Skip to content

Instantly share code, notes, and snippets.

@jmscholen
Last active August 29, 2015 13:57
Show Gist options
  • Save jmscholen/9919292 to your computer and use it in GitHub Desktop.
Save jmscholen/9919292 to your computer and use it in GitHub Desktop.
Personality Quiz HW
#personality quiz by jeff scholen. Iron Yard Rails Engineering Class 4/1/2014
#refactored 4/2/2014
multi_user = {}
calm_questions = {question1: "I like living on the Beach.", question2: "I like living in a mountain cabin.", question3: "I prefer a walk on the beach versus going to a bar.", question4: "I like to be alone with my thoughts.", quesiton5: "I prefer working in an office rather than a coffee shop."}
party_questions = {question1: "I like living in the city.", question2: "When staying at a hotel, I prefer staying on the very high floors.", question3: "I like hanging out at a party with lots of people.", question4: "I like owning a high performance car.", question5: "I like working for start-ups rather than a large stable company.", }
5.times{puts " "}
def check_integer_value(value_to_check)
print "#{value_to_check} -- How would you score yourself?"
verify_integer = false
until verify_integer
@check_integer = Integer(gets) rescue nil
if @check_integer == nil || @check_integer > 5 || @check_integer < 1
print "Needs to be a number between 1-5. Try again:"
else
@check_integer != nil
verify_integer = true
end
end
return @check_integer
end
puts "This is a lifestyle personality test. You will be given a series of statements to score from 1 to 5. The higher the number, the more likely you are to identify with the statement."
5.times{puts " "}
sleep 1
answer = "yes"
while answer == "yes"
puts "Are you ready to begin? Yes or No"
answer = gets.chomp.downcase
if answer == "yes"
puts "Let us begin."
sleep 1
elsif answer == "no"
puts "Okay, come back when you are ready."
exit
else
puts "You apparently are not ready to engage with this test. Good-bye!"
exit
end
5.times{puts " "}
puts "Again, enter a 1 through 5 for each statement. The higher the score, the more you identify with the statement."
sleep 1
5.times{puts " "}
puts "Please enter your first name and last initial:"
name = gets.chomp.downcase
5.times{puts " "}
score_calm = {}
calm_questions.each do |a,b|
check_integer_value(b)
score_calm["#{a}"] = @check_integer
end
score_party = {}
party_questions.each do |a,b|
check_integer_value(b)
score_party["#{a}"] = @check_integer
end
calm_score = 0
party_score = 0
score_calm.each {|a,b| calm_score += b}
score_party.each {|a,b| party_score += b}
final_appraisal_of_user = (party_score < calm_score ? "Shhhhhh, You are a quiet person." : "You are a party animal!")
name[-1]= ""
5.times{puts " "}
puts "#{name.capitalize}, #{final_appraisal_of_user}"
multi_user["#{name.capitalize}"] = "#{final_appraisal_of_user}"
5.times{puts " "}
sleep 1
puts "Do you want to add a user? Yes or No"
answer = gets.chomp.downcase
end
scores_of_users = multi_user.values
total_value_of_all_users = scores_of_users.count
number_of_party_animals = scores_of_users.count("You are a party animal!")
percentage_of_party_animals = (number_of_party_animals.to_f/total_value_of_all_users.to_f) * 100
if multi_user.length > 1
puts "Their were a total of #{multi_user.length} test users."
puts "#{percentage_of_party_animals.round}% of your users were party animals."
else
puts "Not enough users to state statiscal information."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment