当我输入与元素完全相同的答案时,输出为Right:0
和Wrong: 10
。
a1
,a2
,a3
...是我从用户输入的文本框中获得的答案。我该如何解决?
private void checkUsersAnswers() {
Collections.addAll(quizUsersAnswers, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
Collections.addAll(quizAnswers, "Aphrodite", "Apollo", "Ares", "Artemis","Demeter", "Dionysus", "Hades", "Hephaestus", "Hera");
for (int i = 0; i < quizAnswers.size(); i++) {
if (quizUsersAnswers.contains(quizAnswers.get(i))) {
intRight++;
} else {
intWrong++;
}
}
}
private void btnCheckUsersAnswersActionPerformed(java.awt.event.ActionEvent evt) {
checkUsersAnswers();
this.lblMessageRightWrong.setText("Right: "+intRight+"Wrong: "+intWrong);
}
我不知道为什么输出错误。