Source of zonetime.h


  1: // Filename: ZONETIME.H
  2: // Purpose:  Specification file for the "derived" ZoneTime class.
  3: //           This class is "derived from" the "base class" Time.

  5: #ifndef ZONETIME_H
  6: #define ZONETIME_H

  8: #include "TIME.H"

 10: enum ZoneType {EST, CST, MST, PST, EDT, CDT, MDT, PDT};

 12: class ZoneTime : public Time
 13: {
 14: public:

 16:     ZoneTime(/* in */ int      hours = 0,
 17:              /* in */ int      minutes = 0,
 18:              /* in */ int      seconds = 0,
 19:              /* in */ ZoneType zone = EST);
 20:     // Pre:      0 <= hours   <= 23  and  0 <= minutes <= 59
 21:     //       and 0 <= seconds <= 59  and  zone has been assigned
 22:     // Post: Class object is constructed and value of
 23:     //       ZoneTime is set according to the incoming parameters

 25:     // Note that the Increment function does not appear here.
 26:     // The reason is that, unlike the Set and Display functions,
 27:     // the Increment function is *not* being "overridden" with a
 28:     // new definition in this derived ZoneTime class.  Or, looked
 29:     // at another way, to increment a ZoneTime value means exactly
 30:     // the same thing as incrementing a Time value so there is no
 31:     // need to have a new version of the Increment function.  This
 32:     // is, of course, one of the advantages of inheritance.

 34:     // Note that this is a new Set function, since the time zone
 35:     // needs to be set now as well.
 36:     void Set(/* in */ int      hours = 0,
 37:              /* in */ int      minutes = 0,
 38:              /* in */ int      seconds = 0,
 39:              /* in */ ZoneType zone = EST);
 40:     // Pre:      0 <= hours   <= 23  and  0 <= minutes <= 59
 41:     //       and 0 <= seconds <= 59  and  zone has been assigned
 42:     // Post: ZoneTime is set according to the incoming parameters

 44:     // Note that this is a new Display function, since the time zone
 45:     // needs to be displayed as part of the time value now as well.
 46:     void Display() const;
 47:     // Pre:  self is initialized.
 48:     // Post: ZoneTime has been output in the form HH:MM:SS ZZZ
 49:     //       where ZZZ is the time zone


 52: private:

 54:     ZoneType zone;
 55: };

 57: #endif