class Question
attr_accessor :prompt, :answer
def initialize(prompt, answer)
@prompt = prompt
@answer = answer
end
end
p1 = "what color are banana?\n(a)pink\n(b)yellow\n(c)red"
p2 = "what color are apple?\n(a)blue\n(b)purple\n(c)red"
questions = [
Question.new(p1, "b"),
Question.new(p2, "c")
]
def run_test(questions)
answer = ""
score = 0
for question in questions
puts question.prompt
answer = gets.chomp()
if answer == question.answer
score += 1
end
end
puts ("you got " + score.to_s + "/" + questions.length().to_s)
end
run_test(questions)