Package com.marcpg.libpg.data.time
Class Timer
java.lang.Object
com.marcpg.libpg.data.time.Timer
A template for a custom timer.
- Since:
- 0.0.1
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetDone()
Get the time that the timer already ran for.getLeft()
Get the time that's left before the timer finishes.boolean
pause()
Pauses the timer, can be resumed afterward.boolean
resume()
Resumes the timer after it got paused.abstract void
start()
Starts the timer, to decrement the time.abstract void
stop()
Stops the timer, cannot be started again after that.
-
Field Details
-
timer
The time that's ticking down. -
initialTime
The initial time that was set.
-
-
Constructor Details
-
Timer
Creates a new Timer object with a specified starting time.- Parameters:
time
- The starting time. Will be cloned for internal use.
-
-
Method Details
-
start
public abstract void start()Starts the timer, to decrement the time.- See Also:
-
stop
public abstract void stop()Stops the timer, cannot be started again after that. -
getLeft
Get the time that's left before the timer finishes.- Returns:
- The time that's left.
-
getDone
Get the time that the timer already ran for.- Returns:
- The time that's done.
-
pause
public boolean pause()Pauses the timer, can be resumed afterward. Juststop()
but it isn't stopped completely.- Returns:
- true = The timer got paused. false = The timer was already paused, so nothing changed.
-
resume
public boolean resume()Resumes the timer after it got paused.- Returns:
- true = The timer got resumed. false = The timer wasn't paused, so nothing changed.
-