Class Clock

java.lang.Object
  extended byClock

public class Clock
extends java.lang.Object

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

Clock

public Clock(int initHours,
             int initMinutes)
Constructor that initializes to given data.

Method Detail

advance

public void advance(int hours,
                    int minutes)
Advance time by the given number of hours and minutes.


fallBack

public void fallBack()
Method to set the clock back by an hour ("fall back")


run

public void run(int hours,
                int minutes)
Run the clock for the specified number of hours and minutes. Print out the time every minute for that amount of time.


setHours

public void setHours(int newHours)
Mutator method to set the hours


setMinutes

public void setMinutes(int newMinutes)
Mutator method to set the minutes


springForward

public void springForward()
Method to set the clock forward by an hour ("spring forward").


toString

public java.lang.String toString()
Return the current time on the screen in a nice format, e.g., 12:54.