Can someone PLEASE help me with this error I can NOT understand what is
wrong with this code on lines 124 and 145 it’s reading…dynamic
constant assignment Screen = Screen.new for both lines 124 and 125.
here is the script
#Define a class repersenting the console window
class Screen
def cls #Define a method that clears the display area
puts ("\n" * 25) #Scroll the screen 25 times
puts “\a”
end
def pause #Define a method that pauses the display area
STDIN.gets
#execution until the player presses the Enter keyend
end
end
#Define a class repersenting the typing text
class Test
end
#This method displays the 8-ball greeting message
def display_greeting
Console_Screen.cls #clears the display area
#Display a welcome screen
print “\t\t Welcome to the Ruby Typing Challenge game!” +
"\n\n\n\n\n\n\n\n\n\n\n\n\nPress Enter to " +
"Continue. \n\n: "
Console_Screen.pause #Pause the game
end
#Define a method to be uded to present text instructions
def display_instructions
Console_Screen.cls #Clear the display area
puts “\t\t\tInstructions:\n\n” #Display a heading
#Display the game’s instruction
puts %Q{ This test consists of a series of 5 typing challenges.
Each challenge sentence is presented one at a time. To respond
correctly, you must retype each sentence exactly as shown and press
the Enter key.
Your grade will be displayed at the end of the test.
\n\n\n\n\n\n\n\n\n
Press Enter to continue.\n\n}
Console_Screen.pause #Pause the game
End
#Define a method to be used to present typing challanges
def present_test(challange)
Console_Screen.cls #clears the display area
print challange + "\n\n: " #Display the challenge sentence
result = STDIN.gets #Collects the players input
result.chop! #cuts off any remaining characters
#Analyze the player input and see if it is correct
if challenge == result then
#keep track of the number of correctly retyped challenge sentences
$noRight += 1
Console_Screen.cls #Clears the display area
#keep the player informed
print "Correct!\n\nPress Enter to continue."
Console_Screen.pause #pause the game
else
Console_Screen.cls #Clear the display area
#keeps the player informed
print “Incorrect!\n\nPress Enter to continue.”
Console_Screen.pause #Clears the game
end
end
#Define a method to be used to display test results
def determine_grade
Console_Screen.cls #clears the display area
#To pass the test the player must correctly retype 3 sentences
if $noRight >= 3 then
#Inform the payer of the good news
print "You retyped " + $noRight.to_s + " sentence(s) correctly. "
puts "You have passed the typing text!\n\nPress Enter to continue."
else #The player has failed the test
#Inform the player of the bad news
print "You retyped " + $noRight.to_s + " sentence(s) correctly. "
puts "You have failed the typing test!\n\nPress Enter to continue."
end
end
Main Script
Logic-----------------------------------------------------------------------
#Initialize global variable that will be used to keep track of the
number
#of correct retyped sentences
$noRight = 0
#MY PROBLEM IS WITH THESE TWO METHODS!!!
Console_Screen = Screen.new
Typing_Test = Test.new
Typing_Test.display_greeting
Console_Screen.cls
#Prompts the player for premission to begin the text
print "Would you like to text your typing skills? (y/n)\n\n: "
answer = STDIN.gets #Collect player response
answer.chop! #Remove any extra characters appended to the string
#loop until the player enters y or n and do not accept any other input.
until answer == “y” || answer == “n”
Console_Screen.cls #clears the display area
#prompt the player for permission to begin the text
print "Would you like to text your typing skills? (y/n)\n\n: "
answer = STDIN.gets #collect the player response
answer.chop! #remove any appended characters to the string
end
if answer == “n” #See if the player elected to not player
else #The player wants to take the test
end
Console_Screen.cls #Clears the display area
#Invites the player to return and play again
puts “Okay, perhaps another time.\n\n”
Typing_Test.display_instructions
#Display typing challenges and grade each answer by calling on the
#Test objects present test method
Typing_Test.present_test “In the end there can be only one.”
Typing_Test.present_test “Once a great plague swept across the land.”
Typing_Test.present_test “Welcome to Ruby P.ming for the Absolute”
+
" Beginner."
Typing_Test.present_test "There are very few problems in the world " +
“that enough M&Ms cannot fix.”
Typing_Text.present_test "Perhaps today is a good day to die. Fight " +
“besides me and let us die together.”
#Notify the player of the results by executing the Test objects
#determing_grage method
Typing_Test.determine_grade
Console_Screen.pause #pauses the game
Console_Screen.cls #clear the display area
#Thank the player for taking the typing test
puts “Thank you for taking the Ruby Typing Challenge.\n\n”
end