如何使用java为测验系统制作秒表

时间:2012-08-02 19:03:17

标签: java applet keyevent

由于我的大学,我真的被困了。 我需要Java中的代码才能有Stopwatch00:00:00(mm:ss:msms)格式显示时间。我想使用Key事件来运行,暂停和重置计时器。就像我按S一样,秒表开始,P暂停,R重置。  问题是我还想为团队的数字添加关键事件,比如我按1,“团队1”闪烁,最好是发出哔哔声,依此类推2 3 {{ 1}} 4。我无法理解如何做到这一点。

我写这个打印时间只是为了尝试......

5
我自己尝试的东西很多自学,所以我不能理解什么是错的

1 个答案:

答案 0 :(得分:0)

你的意思是:

/**
 * Stopwatch is a simple timer.
 */
public class Stopwatch {

    /**
     * Stopwatch() Initialises a stopwatch.
     */
    public Stopwatch() {
        // Your code here.
    }

    /**
     * elapsed() The elapsed time in milliseconds shown on the stopwatch.
     *
     * @return double  The elapsed time in milliseconds as a double.  Returns -1.0 if no meaningful
     * value is available, i.e. if the watch is reset or has been started and not stopped.
     */
    public double elapsed() {
        // Your code here.
    }

    /**
     * start() Starts the stopwatch and clears the previous elapsed time.
     */
    public void start() {
        // Your code here.
    }

    /**
     * stop() If the stopwatch has been started this stops the stopwatch and calculates the
     * elapsed time.  Otherwise it does nothing.
     */
    public void stop() {
        // Your code here.
    }

    /**
     * reset() Resets the stopwatch and clears the elapsed time.
     */
    public void reset() {
        // Your code here.
    }

    @Override
    public String toString() {
        // Your code here.
    }

} // end class Stopwatch