0
好吧,所以我创建了代码,当我尝试在Eclipse中运行脚本时,出现此错误 未初始化的常量DrvierExam :: Console_Screen(NameError)。 senerio为创建脚本是学生必须采取20个问题,他们将不得不获得75%通过这是15个问题。类名称需要有数组的正确答案,用于收集学生答案的问题和数组。未初始化的常量DrvierExam :: Console_Screen(NameError) - 需要帮助代码
我想我在创建两个数组的写道上,但不知道,并在开始时得到错误。
$ class Screen
def cls
puts ("\n" * 10)
puts "\a"
end
def pause
end
end
class DrvierExam
def display_greeting # This is a method
Console_Screen.cls #Clears the Screen
print "\t\t Welcome To Georgia Department Driver Services" + "\n\nPress Enter to Continue"
Console_Screen.pause
末
def display_instructions
Console_Screen.cls
puts "INSTRUCTIONS:\n\n"
puts "You are starting DMV exam for your drivers licence"
puts "You will be presented with multiple choice question,"
puts "Please type the letter of the correct choice"
puts "Grades will be shown at the end"
puts "Good Luck For the First Licence"
print "Press Enter to Continue"
Console_Screen.pause
end
def CorrectAnswer
test = %w[1B 2D 3A 4A 5C 6B 7B 8A 9C 10D 11B 12C 13D 14D 15D 16C 17C 18B 19D 20A] #Array for real anwer
末
def disp_q(question, q_A, q_B, q_C, q_D, answer)
loop do
Console_Screen.cls
puts question + "\n\n"
puts q_A
puts q_B
puts q_C
puts q_D
print "Type the letter representing your answer: "
answer = []
reply = STDIN.gets
reply.chop!
if answer == reply then
$noRight +=1
end
if reply == "a" or reply == "b" or reply == "c" or reply == "d" then
break
end
end
end
请在此处正确缩进您的代码。 –