class Question
attr_acessor :prompt, :answer
def initialize(prompt, answer)
@prompt = prompt
@answer = answer
end
end
p1 = "What Color are apples?\n(a)red\n(b)purple(c)orange"
p2 = "What Color are bananas?\n(a)pink\n(b)red(c)yellow"
p3 = "What Color are pears?\n(a)yellow\n(b)green(c)orange"
questions = [
Question.new(p1, "a"),
Question.new(p2, "c"),
Question.new(p3, "b")
]
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 + "/" + question.length())
end