Assume the existence of a Time class with the class specification shown below. A
ID: 3546210 • Letter: A
Question
Assume the existence of a Time class with the class specification shown below. Also assume a derived class extendedTime was defined that contains a single additional data member named timeZone (of type string) to hold the time zone (e.g. Eastern Time Zone ETZ, Central Time Zone CTZ, etc) . The derived class also has a constructor that accepts two integer parameters and one string parameter which are used to initialize the hour, minutes and timeZone data members (ETZ is the default time zone), a set function name setTime to set the time (hour, minute, and time zone), a function named getTimeZone that returns the timeZone, and a function named write to display the time on the standard output device in the format hour:minute followed by the time zone.
For this question write the implementation of the write() function of class extendedTime.
class Time {
private:
int hour;
int minute;
public:
Time(int hr=0, int mn= 0); // initializes hour to hr and minute to mn
void setTime(int hr. int mn); // sets the time to hr:mn
int getHour(); // returns hour
int getMinute(); // returns minute
void write(); // displays the time on the standard output device in the format hour:minute.
};
Explanation / Answer
void extendedTime::write() {
cout << this->hour << ":" << this->minute << " " << this->timeZone << endl;
return;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.