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
請在此處正確縮進您的代碼。 –