I'm in the process of creating a simple maths game. I'm trying to create a loop that will display ten questions, one at a time, to a textview. The user will enter the answer into an edittext, press a button, and then question will be validated and the next question in the series of ten will appear in the textview.
I'm just not quite sure how to get to the next question. Any help will be greatly appreciated.
Here's what I've done so far:
int x = 0;
while (x < 10) {
if (i1 == 1) {
answer = q1;
editTextEquation.setText(random1 + "+" + random2);
x++;
}
if (i1 == 2) {
answer = q2;
editTextEquation.setText(random1 + "-" + random2);
x++;
}
if (i1 == 3) {
answer = q3;
editTextEquation.setText(random1 + "/" + random2);
x++;
}
if (i1 == 4) {
answer = q4;
editTextEquation.setText(random1 + "*" + random2);
x++;
}
}
and then the validation button calls this method
private void questions() {
int score = 0;
int i = Integer.parseInt(editText.getText().toString());
if (i == answer) {
editText.setText("Correct");
score++;
} else {
editText.setText("Incorrect");
}
}