我有一个 QuizApplication,它将在用户完成测试后显示结果。我有以下代码,它将测验结果作为字符串返回:
public String getResult() {
int score = 0;
String[] choices;
String scoreB = "";
for (int i = 0; i < test.length; i++) {
if (test[i].getCorrect() == test[i].getAns()) {
score++;
} else {
choices = test[i].getChoice();
scoreB += "Question " + (i + 1) + " : " + test[i].getQn() + "\n<html></br>choices[test[i].getCorrect() - 1] + "\n\n";
}
} // end of for loop
return result;
}
然后我想以MessageDialog的形式显示结果,所以我使用了:
JOptionPane.showMessageDialog(null, newQuiz.getResult()
但是,我想在JOptionPane.showMessageDialog
. 我该怎么做?