Newer
Older
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package GUI.game;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Dániel
*/
public class StopWatch extends Thread
{
private Controller controller;
private int time;
private Boolean isStopped;
public StopWatch(Controller controller)
{
this.controller = controller;
isStopped = true;
}
@Override
public void run()
{
synchronized(this.controller)
{
while( !isStopped )
{
try
{
controller.timeLeft();
sleep(1000);
} catch (InterruptedException ex)
{
System.out.println("int error");
}
}
}
}
public void reset()
{
this.time = 0;
}
public void stopTimer()
{
this.isStopped = true;
}
public void startTimer()
{
this.isStopped = false;
}