Class Timer

java.lang.Object
com.marcpg.libpg.data.time.Timer

public abstract class Timer extends Object
A template for a custom timer.
Since:
0.0.1
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Time
    The initial time that was set.
    protected final Time
    The time that's ticking down.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Timer(Time time)
    Creates a new Timer object with a specified starting time.
  • Method Summary

    Modifier and Type
    Method
    Description
    Get the time that the timer already ran for.
    Get the time that's left before the timer finishes.
    boolean
    Pauses the timer, can be resumed afterward.
    boolean
    Resumes the timer after it got paused.
    abstract void
    Starts the timer, to decrement the time.
    abstract void
    Stops the timer, cannot be started again after that.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • timer

      protected final Time timer
      The time that's ticking down.
    • initialTime

      protected final Time initialTime
      The initial time that was set.
  • Constructor Details

    • Timer

      public Timer(Time time)
      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

      public Time getLeft()
      Get the time that's left before the timer finishes.
      Returns:
      The time that's left.
    • getDone

      public Time 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. Just stop() 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.