Source of zonetime.h


  1: /** @file zonetime.h
  2: Specification file for the "derived" ZoneTime class.
  3: This class is "derived from" the "base class" Time.
  4: */

  6: #ifndef ZONETIME_H
  7: #define ZONETIME_H

  9: #include "time.h"

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

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

 17:     ZoneTime
 18:     (
 19:         int      hours = 0,   //in
 20:         int      minutes = 0, //in
 21:         int      seconds = 0, //in
 22:         ZoneType zone = EST   //in
 23:     );
 24:     /**<
 25:     @pre      0 <= hours   <= 23  and  0 <= minutes <= 59
 26:           and 0 <= seconds <= 59  and  zone has been assigned
 27:     @post Class object is constructed and value of
 28:           ZoneTime is set according to the incoming parameters

 30:     Note that the increment() function does not appear here.
 31:     The reason is that, unlike the set() and display() functions,
 32:     the incremen() function is *not* being "overridden" with a
 33:     new definition in this derived ZoneTime class. Or, looked
 34:     at another way, to increment a ZoneTime value means exactly
 35:     the same thing as incrementing a Time value so there is no
 36:     need to have a new version of the increment() function. This
 37:     is, of course, one of the advantages of inheritance.

 39:     Note that this is a new set() function, since the time zone
 40:     needs to be set now as well.
 41:     */

 43:     ZoneTime
 44:     (
 45:         const ZoneTime& otherTime //in
 46:     );

 48:     ~ZoneTime();

 50:     void set
 51:     (
 52:         int      hours = 0,   //in
 53:         int      minutes = 0, //in
 54:         int      seconds = 0, //in
 55:         ZoneType zone = EST   //in
 56:     );
 57:     /**<
 58:     @pre      0 <= hours   <= 23  and  0 <= minutes <= 59
 59:           and 0 <= seconds <= 59  and  zone has been assigned
 60:     @post ZoneTime is set according to the incoming parameters

 62:     Note that this is a new Display function, since the time zone
 63:     needs to be displayed as part of the time value now as well.
 64:     */

 66:     void display() const;
 67:     /**<
 68:     @pre  self is initialized.
 69:     @post ZoneTime has been output in the form HH:MM:SS ZZZ
 70:           where ZZZ is the time zone
 71:     */

 73: private:
 74:     ZoneType zone;
 75: };

 77: #endif