Time Interval Class
/**
*A time interval has two times in military time, the difference of which can
* be retreived in hours and minutes.
*/
public class TimeInterval
{
private int time1;
private int time2;
/**
*Creates a new time interval with both times at 0.
*/
public TimeInterval()
{
this(0,0);
}
/**
*Creates a new time interval with the given times.
*@param newTime1 Specifies the first time.
*@param newTime2 Specifies the second time.
*/
public TimeInterval(int newTime1, int newTime2)
{
time1=newTime1;
time2=newTime2;
}
/**
*Gets the number of hours in the interval.
*@return Returns the number of hours.
*/
public int getHours()
{
return getDif()/100;
}
/**
*Gets the number of minutes in the interval.
*@return Returns the number of minutes.
*/
public int getMinutes()
{
return getDif()%100;
}
/**
*Calculates the interval between two times.
*@return Return the interval in military time.
*/
private int getDif()
{
int numMinutes;
if (time1