|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectTime
public class Time
This class represents time using hours and minutes (seconds are not represented). Feel free to add any methods that you want.
| Constructor Summary | |
|---|---|
Time(int hour,
int minutes,
java.lang.String amPm)
Initializes the object using specified parameter values. |
|
| Method Summary | |
|---|---|
int |
compareTo(Time time)
Compares two time objects. |
boolean |
equals(java.lang.Object obj)
Compares two time objects. |
static Time |
increaseByMinutes(Time time,
int minutes)
Returns a new time object corresponding to the time we will have after increasing the time parameter by the specified number of minutes. |
java.lang.String |
toString()
Returns a string using the format "hour:minutes am" or "hour:minutes pm". |
| Methods inherited from class java.lang.Object |
|---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Time(int hour,
int minutes,
java.lang.String amPm)
hour - value between 1 and 12, both inclusiveminutes - value between 0 and 59, both inclusiveamPm - either "am" or "pm"
java.lang.IllegalArgumentException - Thrown for invalid hour, minutes, or amPm value. Validity for hour is
verified first, followed by the minutes' validity and the am/pm
value's validity. The thrown exception must use one of the following
messages: "Invalid hour value", "Invalid minutes value", or
"Invalid am/pm value".| Method Detail |
|---|
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int compareTo(Time time)
public static Time increaseByMinutes(Time time,
int minutes)
time - minutes - delta to apply to time parameter
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||