speedscheduler
Class Time

java.lang.Object
  extended by speedscheduler.Time
All Implemented Interfaces:
java.io.Serializable

public class Time
extends java.lang.Object
implements java.io.Serializable

Simple time object to store hour and minute and compare to other Times.

See Also:
Serialized Form

Field Summary
private  int hour
           
private  int minute
           
 
Constructor Summary
Time(int hour, int minute)
          Creates a new Time with the specified hour and minute.
 
Method Summary
 boolean between(Time t1, Time t2)
          Figures out if this time is between the two specified times, t1 and t2, inclusive.
 boolean earlierThan(Time t)
          Figures out if this time is before the specified time t.
 boolean equals(java.lang.Object o)
          Figures out if this time is equal to the specified time.
 int getHour()
          Gets the hour value of this time (0-23).
 int getMinute()
          Gets the minute value of this time (0-59).
 int hashCode()
          Gets this object's hash code
static void main(java.lang.String[] args)
          For unit test only
 void setHour(int hour)
          Sets the hour for this time, must be between 0 and 23.
 void setMinute(int minute)
          Sets the minute for this time, must be between 0 and 59.
 java.lang.String toString()
          Gets a human readable representation of this time, with am/pm and nice formatting.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

hour

private int hour

minute

private int minute
Constructor Detail

Time

public Time(int hour,
            int minute)
Creates a new Time with the specified hour and minute.

Parameters:
hour -
minute -
Method Detail

getHour

public int getHour()
Gets the hour value of this time (0-23).

Returns:

getMinute

public int getMinute()
Gets the minute value of this time (0-59).

Returns:

setHour

public void setHour(int hour)
Sets the hour for this time, must be between 0 and 23.

Parameters:
hour - The new hour.
Throws:
java.lang.IllegalArgumentException - if the hour is out of the range from 0-23.

setMinute

public void setMinute(int minute)
Sets the minute for this time, must be between 0 and 59.

Parameters:
hour - The new minute.
Throws:
java.lang.IllegalArgumentException - if the minute is out of the range from 0-59.

between

public boolean between(Time t1,
                       Time t2)
Figures out if this time is between the two specified times, t1 and t2, inclusive.

Parameters:
t1 -
t2 -
Returns:
True if this time is between the two specified times, false otherwise.

earlierThan

public boolean earlierThan(Time t)
Figures out if this time is before the specified time t.

Parameters:
t -
Returns:
True if this time occurs earlier during the day than Time t.

equals

public boolean equals(java.lang.Object o)
Figures out if this time is equal to the specified time.

Overrides:
equals in class java.lang.Object
Parameters:
t -
Returns:
True if this time is equal, false otherwise.

hashCode

public int hashCode()
Gets this object's hash code

Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

toString

public java.lang.String toString()
Gets a human readable representation of this time, with am/pm and nice formatting. Use this to display the Time for people to read.

Overrides:
toString in class java.lang.Object
Returns:
The human readable time.

main

public static void main(java.lang.String[] args)
For unit test only