Timer

floodsim.model.logic.Timer
See theTimer companion object
final class Timer

A timer that tracks elapsed time in seconds and provides formatting capabilities. This is an immutable class - all operations return new Timer instances.

Value parameters

totalSeconds

the total number of seconds that have elapsed

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def formattedElapsed: String

Returns the elapsed time formatted as a string in MM:SS format.

Returns the elapsed time formatted as a string in MM:SS format.

Attributes

Returns

a formatted string representing the elapsed time in minutes and seconds

def incrementSeconds(amount: Int): Timer

Increments the timer by the specified number of seconds. Returns a new Timer instance with the updated time (immutable operation).

Increments the timer by the specified number of seconds. Returns a new Timer instance with the updated time (immutable operation).

Value parameters

amount

the number of seconds to add to the timer (must be non-negative)

Attributes

Returns

a new Timer instance with the updated elapsed time

Throws
IllegalArgumentException

if amount is negative

def reset(): Timer

Resets the timer to zero elapsed time. Returns a new Timer instance with zero seconds elapsed.

Resets the timer to zero elapsed time. Returns a new Timer instance with zero seconds elapsed.

Attributes

Returns

a new Timer instance with zero elapsed seconds