ruby on rails - 20 questions quiz game app problems? -


I am trying to write a twenty-question app for school, and I have tied a speed.

On line 26, I'm getting the error: 20q2.rb: 26: Warning: String Verbatim Status .

Besides, I have a scoring system to tell the user what their final score is and it prints the score after every question when it is displayed at the end of the quiz.

The code works otherwise, so if someone can help me two problems which I am doing will be great

Here is the code:

  #quotions quesions in a row QANDA = [["Sky is blue?", "Y"], ["Is it dark" Is this a yes or no question? "," Y "], ["Is this a small answer question", "n"], ["Is this program written in rail? "," N "], [" Is this program written in Ruby? "," Y "]] # create a variable for the scoring system # num = 0 # Create a loop to ask questions automatically. #spaces for user input puts" y or n "ans = gets. Chomp ansdown = ans.downcase #compair puts the user input with the correct answer, if ansdown == option [1] #add score and the number to give praise puts Num = num + 1 "right" "#" completely Should be ashamed Ansde == "n" "Wrong" puts #reprint question if answer is invalid! Ansdown! = "Y" & "N" & amp; Y "Y" & amp; "" Puts irreversible input, please try again. Just enter the Y / N. "Repeat the number to put a string score = num.to_s #print score # Convert" You get "+ score +" of 6 questions. "Say fools fools, If the number puts "Lieutenant; = 3," you did a very bad job "# intelligent ELSIF No. 4 puts" great work! "Elsif num == 4" Not bad "end of the end  

The following conditions are incorrect:

  if ansdown! = "Y" & amp; amp; "N" & amp; "y" and "n"   

Because it will be interpreted as the following:

  if (ansdown! = " Y ") & amp; amp; (" N ") & amp; amp; (" Y ") & amp; amp; (" N ")   

What you might want to do :

  If ansdown! = "Y" & Ansdown! = "N" & Ansdown! = "Y" & amp; Ans "!" = "N"   

Or in short, you can:

  if! ["Y", "y", "n" if you have ActiveSupport , You can use the  exclusion?  is also possible (not possible in pure ruby):   

if ["y", "y", "n", "n" ]. Excluded? (Ansdown)

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -