Question: You are given an interface: public interface TimeKeeper { public void reset(); //resets seconds to 0 public void addToSeconds(); //adds 0.01 seconds to seconds. Resets
You are given an interface:
public interface TimeKeeper { public void reset(); //resets seconds to 0 public void addToSeconds(); //adds 0.01 seconds to seconds. Resets to zero if >= 1 hour. public String displayTime(); //returns the formatted time in seconds public void delayTime(int delay); //increments seconds by delay hundredths of a second } You are asked to write a class Watch that implements this interface. It must have an instance variable seconds of type double and a constructor that sets seconds to the value of its int argument.
The methods of the interface must be implemented as per the comments above.
As an example, if the time in seconds is 479.56 then displayTime() should return:
The timer says: 479.6 seconds
The format of the String returned by displayTime() should be precisely as in the example above (but there is no initial space). Hint: Use the String.format() method.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
