ok i have a bit of code i need to repeat, but theres a timer inside and what happens is it repeats 5 times immediately and then the code runs after that, what i want for it to do is run once, and after it has run and the timer has stoped i want it to repeat again, i tried nesting do loops but it didn't work too well, this is my code, i just need it to repeat 5 times,
while (played != 5 ){
System.out.println(play);
if (lives != 0) {
played += 1;
win = 2;
time = 7;
int randGame = 1 + (int)(Math.random() * 5);
gameIndex(randGame,played);
timer.start();
if (win == 0) {
lives -= 1;
}
}
}
static ActionListener taskPerformer = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
time -= 1;
if (time == 1 || win == 1 || win == 0){
timer.stop();
}
}
};