Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/ / clockType . h , the specification file for the class clockType #ifndef H _ ClockType #define H _ ClockType class clockType { public:
clockTypeh the specification file for the class clockType
#ifndef HClockType
#define HClockType
class clockType
public:
void setTimeint hours, int minutes, int seconds;
void getTimeint& hours, int& minutes, int& seconds const;
void printTime const;
void incrementSeconds;
void incrementMinutes;
void incrementHours;
bool equalTimeconst clockType& otherClock const;
clockTypeint hours, int minutes, int seconds;
d clockType;
private:
int hr; variable to store the hours
int min; variable to store the minutes
int sec; variable to store the seconds
;
#endif
Implementation File for the class clockType
#include
#include "clockType.h
using namespace std;
void clockType::setTimeint hours, int minutes, int seconds
if hours && hours
hr hours;
else
hr ;
if minutes && minutes
min minutes;
else
min ;
if seconds && seconds
sec seconds;
else
sec ;
void clockType::getTimeint& hours, int& minutes,
int& seconds const
hours hr;
minutes min;
seconds sec;
void clockType::incrementHours
hr;
if hr
hr ;
void clockType::incrementMinutes
min;
if min
min ;
incrementHours;
void clockType::incrementSeconds
sec;
if sec
sec ;
incrementMinutes;
void clockType::printTime const
if hr
cout ;
cout hr :;
if min
cout ;
cout min :;
if sec
cout ;
cout sec;
bool clockType::equalTimeconst clockType & otherClock const
return hr otherClock.hr
&& min otherClock.min
&& sec otherClock.sec;
clockType::clockTypeint hours, int minutes, int seconds
if hours && hours
hr hours;
else
hr ;
if minutes && minutes
min minutes;
else
min ;
if seconds && seconds
sec seconds;
else
sec ;
clockType::clockTypedefault constructor
hr ;
min ;
sec ;
In Chapter 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. By
using the files provided clockTypeh and clockTypeImp.cpp derive the class extClockType from the
class clockType by adding a member variable to store the time zone. Override a member function
printTime and add constructors to make the derived class functional. Finally, test your program by
setting the time to : : CST and output it on the console.
Submit a header file consisting of the derived class declaration, a cpp file which include member function
definitions of the derived class, and another cpp file which includes the main function. Copy and paste the
screenshot of the output here
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started