An object of the class Timer is used to indicate when a certain amount of time (in seconds) has elapsed, after which it provides a “DING”. The required data field is remainingTime which is the number of seconds until the “DING”. When a Timer object is constructed, it is set with the desired number of seconds. When the timer “ticks”, it is one second closer to the “DING”. This is represented with the tick() method. The dingCheck() method indicates whether the timer should be “DINGING”. Provide the code for the constructor method, and the methods getRemainingTime(), tick(), and dingCheck(). public class Timer { // Methods // Data private int remainingTime; }
An object of the class Timer is used to indicate when a certain amount of time (in seconds) has elapsed, after which it provides a “DING”. The required data field is remainingTime which is the number of seconds until the “DING”. When a Timer object is constructed, it is set with the desired number of seconds. When the timer “ticks”, it is one second closer to the “DING”. This is represented with the tick() method. The dingCheck() method indicates whether the timer should be “DINGING”.
Provide the code for the constructor method, and the methods getRemainingTime(), tick(), and dingCheck().
public class Timer
{ // Methods
// Data
private int remainingTime;
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps