we are coding a quiz on netbeans basically what the submit button does is when you click it, it's supposed to look for a match of the answer you selected from the correctAns string and adds a point if it's correct, if not it displays "wrong answer" on the jlabel and moves on with the next question but,,, it doesn't..what's wrong with the code?
tysm! apologies as i only have very limited knowledge of java.
the addedScore is defined from
int randNumbersSet[] = new int[15];
int questionNo = 0, legitQuestionNo = 0, newScore = 0, oldScore = 0, addedScore = 0;
String answer = "";
oldScore is from a method called scoreCounter
public int scoreCounter(int oldScore){
return(oldScore + addedScore);
}
so if you score +1, addedScore will be added to oldScore
private void SubmitActionPerformed(java.awt.event.ActionEvent evt) {
if(answer.equals(correctAnsSet[randNumbersSet[questionNo]])){
addedScore = 1;
}
else{
addedScore = 0;
quizQuezo.setText("Sorry, wrong answer.");
}
oldScore = Integer.parseInt(Score.getText());
newScore = scoreCounter(oldScore);
if(questionNo == randNumbersSet.length - 1){
quizQuezo.setText("Game Over!");
this.setVisible(false);
QuizEnd h1 = new QuizEnd(newScore);
h1.setVisible(true);
}
else{
questionNo++;
testSetter();
}
}
What I have tried:
well i haven't tried anything but identify the problem. as i've said before i'm not knowledgeable enough to solve this but i need to as it's for a school requirement.