I have the following code lines. I need to check each button (there are 4: a,b,c,d) and compare if the answer is right. If it is, I say that the button set its color to green.
But I need to reduce this code, with a iterator or something like that, because if increase the quantity of buttons will be more complicated.
if(currentQuestion.getOptA().equals(currentQuestion.getAnswer()))
{
buttonA.setBackgroundColor(ContextCompat.getColor(getApplicationContext(),R.color.lightGreen));
} else if(currentQuestion.getOptB().equals(currentQuestion.getAnswer()))
{
buttonB.setBackgroundColor(ContextCompat.getColor(getApplicationContext(),R.color.lightGreen));
} else if(currentQuestion.getOptC().equals(currentQuestion.getAnswer()))
{
buttonC.setBackgroundColor(ContextCompat.getColor(getApplicationContext(),R.color.lightGreen));
} else if(currentQuestion.getOptD().equals(currentQuestion.getAnswer()))
{
buttonD.setBackgroundColor(ContextCompat.getColor(getApplicationContext(),R.color.lightGreen));
}