Put all work into a directory hw5
of your Git project and push it once a day. Don't put any code into packages. Don't put any code into a src
subdirectory.
You will write a Stopwatch
(note the lowercase w) class that implements the stopwatch described at this page: https://en.wikipedia.org/wiki/Stopwatch.
Implement a class Stopwatch
that implements the MoveableShape
interface from chapter 4 of the book. (Note that this code changed recently.)
Here is code to run the stopwatch. Supply the radius on the command line, e.g.
java AnimationTester 400
Also implement a class Dial
. You'll need two instances in the StopWatch
. For easy testing, make it implement Icon
. Here is a tester. (The second parameter is true
for including three levels of ticks.)
Provide javadoc for all classes and methods.
Follow the description in the Wiki page for the behavior of the buttons, except that we have no way of holding the second button down for the freeze mode. Instead, make it toggle the freeze mode when the stopwatch is running. That is:
Hints:
ArrowHead.java
.MultilineText.java
in the Violet source code.Instant.now
to get the correct time when the stopwatch starts. Whenever move
is called and the stopwatch is not frozen, call Instant.now
again, compute the difference (Duration.between
), convert to nanoseconds, and then into angles.