1: /** @file zonetime.cpp
2: Implementation file corresponding to zonetime.h.
3: */
5: #include <iostream>
6: using namespace std;
8: #include "zonetime.h"
10: //******************************************************************
11: ZoneTime::ZoneTime
12: (
13: int hours, //in
14: int minutes, //in
15: int seconds, //in
16: ZoneType zone //in
17: )
18: :Time(hours, minutes, seconds)
19: {
20: this->zone = zone;
21: cout << "\nNow in constructor for derived class ZoneTime ...";
22: cout << "\nZoneTime value is: "; this->display();
23: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n');
24: }
26: ZoneTime::ZoneTime
27: (
28: const ZoneTime& otherTime //in
29: )
30: //Not needed, but inserted to show when a copy is being made.
31: {
32: hours = otherTime.hours;
33: minutes = otherTime.minutes;
34: seconds = otherTime.seconds;
35: zone = otherTime.zone;
37: cout << "\nNow in copy constructor for derived class ZoneTime ...";
38: cout << "\nTime value is: "; this->display();
39: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n');
40: }
42: ZoneTime::~ZoneTime()
43: //Not needed, but inserted to help show destruction order.
44: {
45: cout << "\nNow in destructor for derived class ZoneTime ...";
46: cout << "\nZoneTime value is: "; this->display();
47: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n');
48: }
50: //******************************************************************
51: void ZoneTime::set
52: (
53: int hours, //in
54: int minutes, //in
55: int seconds, //in
56: ZoneType timeZone //in
57: )
58: {
59: Time::set(hours, minutes, seconds);
60: zone = timeZone;
61: }
63: //******************************************************************
64: void ZoneTime::display() const
65: {
66: static char zoneString[8][4] =
67: {
68: "EST", "CST", "MST", "PST", "EDT", "CDT", "MDT", "PDT"
69: };
70: Time::display();
71: cout << ' ' << zoneString[zone];
72: }