/* * GameClock.java * * Created on 2005年7月18日, 上午11:00 * * To change this template, choose Tools Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */
package com.j2medev.gameclock; import java.util.TimerTask; /** * * @author Administrator */ public class GameClock extends TimerTask{
private int timeLeft = 60;//时钟的默认时间 private boolean pause = false; /** Creates a new instance of GameClock */ public GameClock() { }
public GameClock(int value){ timeLeft = value; }
public void run(){ if(!pause){ timeLeft--; } }
public void pause(){ pause = true; }
public void resume(){ pause = false; }
public int getTimeLeft(){ return timeLeft; }
public void setTimeLeft(int _value){ this.timeLeft = _value; } }