CS 136 Assignment 9
For this assignment you are to write a program to emulate a stopwatch. It will
have a display showing the current time as well as buttons to start the
watch, pause it, and clear the time. A demo version is shown below.
The current system time in milliseconds (thousandths of a second) is available
by executing System.currentTimeMillis();, which returns a
long integer representing the number of milliseconds since
January 1, 1970. If you save the time the start button is clicked in
startTime then System.currentTimeMillis() - startTime
will return the number of milliseconds since the timer was started.
The method String timeString(long time) (included in class
WatchThread) converts the milliseconds into a string suitable for
showing in the display field.
I have provided you with two files: Timer.java and WatchThread.java, which
provide a frame and the skeleton of a class extending Thread. Please
complete the program so that your stopwatch behaves like the demo.
The goal of this assignment is to gain some experience with the Thread class.
What to hand in
Nothing! This will be done as a group exercise in lab.