I'm doing a gui number game where the user has to guess 3 random numbers, the result of each guess is outputted in 3 textfields
the random numbers are in an array as shown (In the actionPerformed method)
int i = 0, Count = 0;
RandomNumber = Math.round(Math.random() * 9);
RandomNumber[i + 1] = Math.round(Math.random() * 9);
RandomNumber[i + 2] = Math.round(Math.random() * 9);
so is the textfields
TextAreas = FirstTextBox;
TextAreas[i+1] = SecondTextBox;
TextAreas[i+2] = ThirdTextBox;
then ive got if statements like
if(e.getActionCommand().equals("0")){
if (RandomNumber == 0){
TextAreas.setText(String.valueOf("Correct...."));
i++;
}
else{
TextAreas.setText(String.valueOf("Incorrect, Try Again"));
}
but the integer i keeps getting reset to zero, how would i stop this?
(If the guess is correct, 1 should be added to the value i, so that it then uses the next random number and the next textfield)
please help
GUI game ... help
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard