Want to implement if conditions for WRONG,CORRECT and UNANSWERED QUESTIONS which will display correct,wrong and score at last.App runs but its not showing the correct score for it.
Want to implement below format in quiz-
if(wrong_Click_radioButton)
{
wrong++;
nextquestion++;
}
if(correct_Click_radioButton)
{
correct++;
nextquestion++;
}
if(not_clicked_any_radioButton)
{
nextquestion++;
}
if(last_question_checking)
{
score display;
switch to next android activity;
}
The code which if implemented shows wrong logic
if (userSelection == -1) {
Toast.makeText(QuizActivity.this, "You Left the Questions-->" + radioGroup.getCheckedRadioButtonId() + "score-->" + score, Toast.LENGTH_LONG).show();
} else if (userSelection == correctAnswerForQuestion) {
correct++;
// correct answer
Toast.makeText(QuizActivity.this, "Correct Answer" + "Correct-" + correct + "Wrong" + wrong, Toast.LENGTH_LONG).show();
} else {
wrong++;
// failed question
Toast.makeText(QuizActivity.this, "Wrong Answer" + "Correct-" + correct + "Wrong" + wrong, Toast.LENGTH_LONG).show();
return;
}
currentQuizQuestion++;
if (currentQuizQuestion >= quizCount) {
score = correct - wrong;
Toast.makeText(QuizActivity.this, "End of the Quiz Questions" + score, Toast.LENGTH_LONG).show();
} else {
firstQuestion = parsedObject.get(currentQuizQuestion);
quizQuestion.setText(firstQuestion.getQuestion());
String[] possibleAnswers = firstQuestion.getAnswers().split(",");
uncheckedRadioButton();
optionOne.setText(possibleAnswers[0]);
optionTwo.setText(possibleAnswers[1]);
optionThree.setText(possibleAnswers[2]);
optionFour.setText(possibleAnswers[3]);
return;
}
}
});
Aucun commentaire:
Enregistrer un commentaire