Class Time

java.lang.Object
  extended by Time

public class Time
extends Object

Time represented as attributes hours and minutes.

Version:
1 March 2006

Constructor Summary
Time()
          Constructor for objects of class Time that sets time to zero (0:00).
Time(int minutes)
          Constructor for objects of class Time that sets time to the number of minutes specified.
Time(int hours, int minutes)
          Constructor for objects of class Time that sets time to the number of hours and minutes specified.
 
Method Summary
 boolean equals(Time t)
          Determine if two Time objects are equal.
 int getHours()
          Retrieve the hours.
 int getMinutes()
          Retrieve the minutes.
 Time increment(Time timeIncrement)
          Create a new Time object whose value is the current object's time incremented by the parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Time

public Time()
Constructor for objects of class Time that sets time to zero (0:00).


Time

public Time(int minutes)
Constructor for objects of class Time that sets time to the number of minutes specified. The time is normalized to the equivalent number of hours and minutes such that minutes is in the range 0..59 inclusive.

Parameters:
minutes - the number of minutes

Time

public Time(int hours,
            int minutes)
Constructor for objects of class Time that sets time to the number of hours and minutes specified. The time is normalized to the equivalent number of hours and minutes such that minutes is in the range 0..59 inclusive.

Parameters:
hours - the number of hours
minutes - the number of minutes
Method Detail

getHours

public int getHours()
Retrieve the hours.

Returns:
the hours

getMinutes

public int getMinutes()
Retrieve the minutes.

Returns:
the minutes

increment

public Time increment(Time timeIncrement)
Create a new Time object whose value is the current object's time incremented by the parameter. A parameter of null is equivalent to new Time().

Parameters:
timeIncrement - the amount to increment by
Returns:
new time object

equals

public boolean equals(Time t)
Determine if two Time objects are equal. Two Time objects are equal if and only if they have the same number of hours and same number of minutes. (Returns false if the specified Time is null.)

Parameters:
t - the Time object to compare with this Time
Returns:
true if the hours and minutes are the same; false otherwise