English 中文(简体)
查询题数列表的继承内容
原标题:inheritance for an arraylist of quizQuestions

Edit: 谢谢so much my program is finally running .

我编辑添加选择的代码, 以便读取一系列连接的数字和白空格; 我还修改了复选解答方法, 但每当我输入正确答案时, 仍然计算错误, 以下为我的代码 :

          public void addChoice(String choice, boolean correct){
      super.addChoice(choice, correct);
      if(correct == true){
           count++;
           choiceString +=   "" + count+" " ;
           answers.add(choiceString);
            }
       super.setAnswer(choiceString.trim());
     }            


     public boolean checkAnswer( String response )
   {
    super.checkAnswer(response);
    boolean ok = false;
    response = response.trim();
    String correctAnswers [] = response.split(" ");
    for(int i=0; i<correctAnswers.length;i++){
        if (answers.contains(correctAnswers[i]))
        { ok = true;}
        else
        {  ok=false;}
     }
    return ok;
   }

" 强 " 我的问题:

对于我的问题,第一个和第二个选项是正确的。所以,他的用户可以输入一、二、一、二、二、一、一,这样他/她就可以在问题上获得完全分数;当我键入除上面所列选项之外的任何其他选项时,我应该恢复零。所以我的问题是,我的支票回答方法总是由于某种原因恢复到真实的状态,所以无论我输入什么类型,即使我输入错误的答案,它也算得上是真实的。所以,我需要帮助来完成这部分。

谢谢

问题回答

您总是设置在 true AnyChoiceQ question check Answer :

if(true)
     {ok = true;}

我想你是想说:

if (answers.contains(correctAnswers[i]))
    ok = true;

你的问题在于(如果)什么,如果它永远燃烧。回答是真实的。我想你指的是(回答)如果(回答)是真实的。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...