public class TimeDuration
extends java.lang.Object
Constructor and Description |
---|
TimeDuration(int initialSeconds)
Construct a time duration with a given initial number of seconds.
|
TimeDuration(int initialMinutes,
int initialSeconds)
Construct a time duration with a given initial value for minutes
and seconds.
|
Modifier and Type | Method and Description |
---|---|
TimeDuration |
add(TimeDuration val)
Returns a TimeDuration whose value is (this + val).
|
boolean |
equals(java.lang.Object x)
Compares this TimeDuration with the specified Object for equality.
|
int |
minutes()
Accessor to number of minutes.
|
int |
seconds()
Return duration as seconds.
|
TimeDuration |
subtract(TimeDuration val)
Returns a TimeDuration whose value is (this - val).
|
java.lang.String |
toString()
Return a displayable representation of this time interval.
|
public TimeDuration(int initialSeconds)
initialSeconds
- integer value of seconds public TimeDuration(int initialMinutes, int initialSeconds)
initialMinutes
- integer value of minutesinitialSeconds
- integer value of seconds public int minutes()
public int seconds()
public TimeDuration add(TimeDuration val)
val
- value to be added to this TimeDuration.public TimeDuration subtract(TimeDuration val)
val
- value to be subtracted from this TimeDuration.java.lang.ArithmeticException
- if result would be negative.public boolean equals(java.lang.Object x)
equals
in class java.lang.Object
x
- Object to which this TimeDuration is to be compared.public java.lang.String toString()
toString
in class java.lang.Object
0:55
1:23
11:42
0:06