我应该如何完成以下测验程序?

上周,我被要求编写一个3型问题测验,现在我被要求使用软件包,但我无法更改所提供的代码,我在这一点上停留了6天,无法弄清楚该怎么做,如何使其工作 因此,我应该怎么做才能使此测验程序正常工作并给出以下结果(例如): Java测验。测验 测验有3个问题。 问题1(赋予值):“黄色”一词中有多少个字符? 答:6 那就对了! 问题2(三选):一周中有几天? (0)6天 (1)7天 (2)7天 答:0 错误的答案! 问题3(单词输入):类的实例称为_ _ _ _ _ _ _。 答案:对象 那就对了! 您有3个问题中有2个回答正确! _______________________________________________________ 我无法更改且无法从其开始的代码如下:

package quiz;

import quiz.questions.Question;
import quiz.questions.ValueInputQuestion;
import quiz.questions.ThreeChoiceQuestion;
import quiz.questions.MissingWordQuestion;

public class Quiz {

  public static void main(String[] args) {
    Question[] questions = new Question[3];
    questions[0] = new ValueInputQuestion("How many characters in the word 'Yellow'?", 6);
    questions[1] = new ThreeChoiceQuestion("How many days in the week?", 1, "6 Days", "7 Days", "8 Days");
    questions[2] = new MissingWordQuestion("The instance of a class is called _ _ _ _ _ _.", "Object");
    int numQuestions = questions.length;
    int correctAnswers = 0;
    System.out.println("This quiz has " + numQuestions + " questions.");
    for (int i = 0; i < numQuestions; ++i) {
      System.out.print("Question " + (i+1) + " ");
      boolean correct = questions[i].ask();
      if (correct) {
        System.out.println("That's right!");
        ++correctAnswers;
      } else {
        System.out.println("Wrong Answer!");
      }
    }
    System.out.println("You have " + correctAnswers + " out of " + numQuestions + " questions answered correctly!");
  }

}

请帮忙,我真的很感激 在此先感谢您的帮助和时间。

评论