コード例 #1
0
ファイル: Quiz.java プロジェクト: evertonlga/mobitcasestudy
  public void answerQuestion(int userAnswer) {
    Result res = getPartialResult().clone();
    setResponded(false);
    Question q = questionGenerator.getQuestion();
    System.out.println(q);
    System.out.println(userAnswer);
    if (q.getAnswer() == userAnswer) {
      res.setScore(result.getScore() + 1);
      res.updateResultByCategory(q.getCategory(), true);
    } else {
      res.updateResultByCategory(q.getCategory(), false);
    }

    long acumulatedTimeBefore = getAcumulatedTime();
    setAcumulatedTime(acumulatedTimeBefore + (System.currentTimeMillis() - getInitialTime()));
    setInitialTime(System.currentTimeMillis());
    res.setTime(getAcumulatedTime());
    setPartialResult(res);

    setResponded(true);
    configure(numberOfQuestions - 1);
  }