Class Time

java.lang.Object
  extended by Time

public class Time
extends Object

Holds a time instance (hrs, mins, secs).

Version:
Summer2014
Author:
Tina Comston

Constructor Summary
Time()
          Default constructor for objects of class Time.
Time(int inTTLsecs)
          Constructor for objects of class Time.
Time(int inhrs, int inmins, int insecs)
          Constructor for objects of class Time.
 
Method Summary
 Time getDifference(Time endTime)
          get the difference between times.
 int getHrs()
          get the hrs.
 int getMins()
          get the mins.
 int getSecs()
          get the secs.
 int getTotalSecs()
          get the number of secs represented by the Time object.
 void setHrs(int inhrs)
          set the hrs.
 void setMins(int inmins)
          set the mins.
 void setSecs(int insecs)
          set the secs.
 String toString()
          format a String with the time as HH:MM:SS.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Time

public Time()
Default constructor for objects of class Time. Default value for all instance variables is 0.


Time

public Time(int inTTLsecs)
Constructor for objects of class Time. The total number of seconds are provided. Compute the hours, minutes, and seconds from the value of total seconds.

Parameters:
inTTLsecs - total seconds.

Time

public Time(int inhrs,
            int inmins,
            int insecs)
Constructor for objects of class Time.

Parameters:
inhrs - hrs of time.
inmins - mins of time.
insecs - secs of time.
Method Detail

getDifference

public Time getDifference(Time endTime)
get the difference between times.

Parameters:
endTime - The end time.
Returns:
Time The difference between this time and the end time.

getHrs

public int getHrs()
get the hrs.

Returns:
int The hour of the time.

getMins

public int getMins()
get the mins.

Returns:
int The mins of the time.

getSecs

public int getSecs()
get the secs.

Returns:
int The secs of the time.

getTotalSecs

public int getTotalSecs()
get the number of secs represented by the Time object.

Returns:
int This Time object as a number of secs.

setHrs

public void setHrs(int inhrs)
set the hrs.

Parameters:
inhrs - hrs of the time.

setMins

public void setMins(int inmins)
set the mins.

Parameters:
inmins - mins of the time.

setSecs

public void setSecs(int insecs)
set the secs.

Parameters:
insecs - secs of the time.

toString

public String toString()
format a String with the time as HH:MM:SS.

Overrides:
toString in class Object
Returns:
String The time in HH:MM:SS format.