未初始化的常量DrvierExam :: Console_Screen(NameError) - 需要协助代码

时间:2011-10-12 15:32:30

标签: ruby eclipse

好的,所以我创建了代码,当我尝试在Eclipse中运行脚本时,我遇到了这个错误 未初始化的常量DrvierExam :: Console_Screen(NameError)。 senerio用于创建脚本是学生必须采取20个问题,他们必须得到75%通过这是15个问题。类名需要有一个数组,正确回答问题和数组,收集学生的答案。

我认为我在创建两个阵列的写入轨道上,但不确定,并在开始时收到错误。

$ 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  

1 个答案:

答案 0 :(得分:0)

您将“Screen”类称为“Console_Screen”。更改所有对Screen的引用,它应该可以正常工作。