samedi 27 juin 2015

condition based on a timer

I was thinking about using a Timer class to do this but I dont really know how to implement this. Here is what I need

Timer timer = new Timer();
While(true){
    if (condition1){
       do something
       timer.reset (set the timer back to 0)
       }
    if (timer >= 20 seconds){
       do something
       (something will happen here that will make condition1 to be true)
       }
     else {
        start the timer 
        }
}

How do I go about implementing something like this? It doesn't necessarily have to be using a Timer i guess.

Aucun commentaire:

Enregistrer un commentaire