jeudi 14 mars 2019

Why is it displaying my answer as being correct, if i select all the check boxes?

I have four checkboxes along with a textview that displays a question. I am trying to create a simple multiple choice quiz with check boxes.I managed to display a toast to the user if they select the correct answer. and a toast if they select a wrong answer. The problem that i'm having is if the user selects all the answer it gets counted as being correct. Can someone help me with this. The result variables stores the check boxes result as a string and i'm comparing it to the correct answer.

            if(result1 == firstQuestion.getCorrectAnswer() && result2 == firstQuestion.getSecondCorrectAnswer()){
                    currentScore = currentScore + 1 + userScore;
                    Intent i = new Intent(CheckBoxQuestions.this, ResultScreen.class);
                    i.putExtra("finalScore",currentScore);
                    startActivity(i);

                }else{
                    Toast.makeText(CheckBoxQuestions.this, "Incorrect", Toast.LENGTH_SHORT).show();
                    currentScore = currentScore + 0 + userScore;
                    Intent i = new Intent(CheckBoxQuestions.this, ResultScreen.class);
                    i.putExtra("finalScore",currentScore);
                    startActivity(i);

                }




        }
    });

} 




Aucun commentaire:

Enregistrer un commentaire