Source of zonetime.cpp


  1: // Filename: ZONETIME.CPP
  2: // Purpose:  Implementation file corresponding to ZONETIME.H.

  4: #include <iostream>
  5: using namespace std;

  7: #include "ZONETIME.H"
  8: #include "PAUSE.H"

 10: // Additional private members of class ZoneTime:
 11: //     ZoneType zone;


 14: //******************************************************************
 15: ZoneTime::ZoneTime(/* in */ int      hours,
 16:                    /* in */ int      minutes,
 17:                    /* in */ int      seconds,
 18:                    /* in */ ZoneType zone)
 19:          :Time(hours, minutes, seconds)
 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
 24: {
 25:     this->zone = zone;
 26:     // cout << "Now in constructor for derived class ZoneTime ... \n";
 27:     // Pause(0);
 28: }


 31: //******************************************************************
 32: void ZoneTime::Set(/* in */ int      hours,
 33:                    /* in */ int      minutes,
 34:                    /* in */ int      seconds,
 35:                    /* in */ ZoneType timeZone)
 36: // Pre:      0 <= hours   <= 23  and  0 <= minutes <= 59
 37: //       and 0 <= seconds <= 59  and  newZone has been assigned
 38: // Post: ZoneTime is set according to the incoming parameters
 39: {
 40:     Time::Set(hours, minutes, seconds);
 41:     zone = timeZone;
 42: }


 45: //******************************************************************
 46: void ZoneTime::Display() const
 47: // Pre:  self is initialized.
 48: // Post: Time has been output in the form HH:MM:SS ZZZ
 49: //       where ZZZ is the time zone
 50: {
 51:     static char zoneString[8][4] =
 52:     {
 53:         "EST", "CST", "MST", "PST", "EDT", "CDT", "MDT", "PDT"
 54:     };
 55:     Time::Display();
 56:     cout << ' ' << zoneString[zone];
 57: }