java.lang.ObjectClock
A class for a clock. The client can set values for the current hour and minute, advance the clock by a given amount of time or by one minute, get the current time as a string, put the clock forward by an hour (to "spring forward"), put the clock backward by an hour (to "fall back"), or "run" the clock for a specified amount of time.
| Constructor Summary | |
Clock(int initHours,
int initMinutes)
Constructor that initializes to given data. |
|
| Method Summary | |
void |
advance(int hours,
int minutes)
Advance time by the given number of hours and minutes. |
void |
fallBack()
Method to set the clock back by an hour ("fall back") |
void |
run(int hours,
int minutes)
Run the clock for the specified number of hours and minutes. |
void |
setHours(int newHours)
Mutator method to set the hours |
void |
setMinutes(int newMinutes)
Mutator method to set the minutes |
void |
springForward()
Method to set the clock forward by an hour ("spring forward"). |
java.lang.String |
toString()
Return the current time on the screen in a nice format, e.g., 12:54. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public Clock(int initHours,
int initMinutes)
| Method Detail |
public void advance(int hours,
int minutes)
public void fallBack()
public void run(int hours,
int minutes)
public void setHours(int newHours)
public void setMinutes(int newMinutes)
public void springForward()
public java.lang.String toString()