Source of time2.h


  1: // Filename: TIME2.H
  2: // Purpose:  Extends the class in TIME1.H by adding two constructors.

  4: #ifndef TIME2_H
  5: #define TIME2_H

  7: class Time
  8: {
  9: public:

 11:     Time();
 12:     // Default constructor
 13:     // Pre:  none
 14:     // Post: Class object is constructed and the time is 00:00:00.
 15:     //       That is, hours, minutes and seconds all have value 0.

 17:     Time(/* in */ int hoursInitial,
 18:          /* in */ int minutesInitial,
 19:          /* in */ int secondsInitial);
 20:     // Constructor
 21:     // Pre:      0 <= hoursInitial   <= 23
 22:     //           0 <= minutesInitial <= 59
 23:     //       and 0 <= secondsInitial <= 59
 24:     // Post: Class object is constructed.
 25:     //       The time is set according to the incoming parameters.


 28:     void Set(/* in */ int hoursNew,
 29:              /* in */ int minutesNew,
 30:              /* in */ int secondsNew);
 31:     // Pre:  0 <= hoursNew   <= 23
 32:     //       0 <= minutesNew <= 59
 33:     //       0 <= secondsNew <= 59
 34:     // Post: Time is set according to the incoming parameters.

 36:     void Increment();
 37:     // Pre:  none
 38:     // Post: Time has been advanced by one second, with
 39:     //       23:59:59 wrapping around to 00:00:00.

 41:     void Display() const;
 42:     // Pre:  none
 43:     // Post: Time has been output in the form HH:MM:SS.


 46: private:

 48:     int hours;
 49:     int minutes;
 50:     int seconds;
 51: };

 53: #endif