Skip to content

Instantly share code, notes, and snippets.

@shosanna
Created October 17, 2013 17:54
Show Gist options
  • Save shosanna/7029333 to your computer and use it in GitHub Desktop.
Save shosanna/7029333 to your computer and use it in GitHub Desktop.
score = 0
questions.each do |question|
invalid_answer = true
while invalid_answer
puts question["text"]
question["answers"].each_with_index do |answer, index|
values = ["a","b","c","d"]
puts "#{values[index]}) #{answer}"
end
answer = gets.strip.downcase
values = ["a","b","c","d"]
if values.index(answer)
invalid_answer = false
if values.index(answer) == question["correct"]
puts "Spravne!"
score += 1
else
puts "Spatne"
correct_answ_index = question["correct"]
correct_answ = question["answers"][correct_answ_index]
puts "Spravna odpoved je #{correct_answ}"
end
else
puts "Spatny format, prosim odpovezte a,b,c nebo d"
end
end
end
puts "GRATULUJI! Ziskla jste #{score} bodu z 9"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment