Question: In Chapter 10 , the class clockType was designed to implement the time of day in a program. Certain applications, in addition to hours, minutes,

In Chapter 10, the class clockType was designed to implement the time of day in a program. Certain applications, in addition to hours, minutes, and seconds, might require you to store the time zone. Derive the class extClockType from the class clockType by adding a member variable to store the time zone. Add the necessary member functions and constructors to make the class functional. Also, write the definitions of the member functions and the constructors. Finally, write a test program to test your class.

There are 5 files total.

I need help with these 3 files:

extClockType.h

extClockTypeImp.cpp

main.cpp

These are the two supplied files.

clockType.h

//clockType.h, the specification file for the class clockType #ifndef H_ClockType #define H_ClockType class clockType { public: void setTime(int hours, int minutes, int seconds);

void getTime(int& hours, int& minutes, int& seconds) const;

void printTime() const;

void incrementSeconds();

void incrementMinutes();

void incrementHours();

bool equalTime(const clockType& otherClock) const;

clockType(int hours, int minutes, int seconds);

clockType(); private: int hr; int min; int sec; };

#endif

clockTypeImp.cpp

//Implementation File for the class clockType #include #include "clockType.h" using namespace std; void clockType::setTime(int hours, int minutes, int seconds) { if (0 <= hours && hours < 24) hr = hours; else hr = 0;

if (0 <= minutes && minutes < 60) min = minutes; else min = 0;

if (0 <= seconds && seconds < 60) sec = seconds; else sec = 0; }

void clockType::getTime(int& hours, int& minutes, int& seconds) const { hours = hr; minutes = min; seconds = sec; }

void clockType::incrementHours() { hr++; if (hr > 23) hr = 0; }

void clockType::incrementMinutes() { min++; if (min > 59) { min = 0; incrementHours(); } }

void clockType::incrementSeconds() { sec++;

if (sec > 59) { sec = 0; incrementMinutes(); } }

void clockType::printTime() const { if (hr < 10) cout << "0"; cout << hr << ":";

if (min < 10) cout << "0"; cout << min << ":";

if (sec < 10) cout << "0"; cout << sec; }

bool clockType::equalTime(const clockType& otherClock) const { return (hr == otherClock.hr && min == otherClock.min && sec == otherClock.sec); }

clockType::clockType(int hours, int minutes, int seconds) { if (0 <= hours && hours < 24) hr = hours; else hr = 0;

if (0 <= minutes && minutes < 60) min = minutes; else min = 0;

if (0 <= seconds && seconds < 60) sec = seconds; else sec = 0; }

clockType::clockType() //default constructor { hr = 0; min = 0; sec = 0; }

Need help with the following files:

extClockType.h

//extClockType.h, the specification file for the class extClockType #ifndef H_extClockType #define H_extClockType class extClockType { }; #endif

extClockTypeImp.cpp

//Implementation File for the class extClockType

#include #include "extClockType.h" using namespace std;

main.cpp

// main function using namespace std; #include #include #include "clockType.h" #include "extClockType.h" int main() {

}

Build Errors

error: no matching function for call to 'extClockType::setTime(int, int, int, const char [4])' time2.setTime(12, 45, 59, "PST");
void clockType::setTime(int, int, int) void clockType::setTime(int hours, int minutes, int seconds)

TEST CONTENTS

using namespace std; TEST(Cyl, 1) { extClockType time1(5, 10, 34, "CST"); extClockType time2; testing::internal::CaptureStdout(); cout << "Time 1: "; time1.printTime(); cout << endl; time2.setTime(12, 45, 59, "PST"); cout << "Time 2: "; time2.printTime(); cout << endl; time2.incrementSeconds(); cout << "After incrementing time2 by one second, Time 2: "; time2.printTime(); }

Need help with the following files:

extClockType.h

extClockTypeImp.cpp

main.cpp

Including the use of these functions:

extClockType::setTime(int, int, int, const char [4])' time2.setTime(12, 45, 59, "PST");
void clockType::setTime(int, int, int) void clockType::setTime(int hours, int minutes, int seconds)

And satisfying the build test.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!