Question: C++ source code include #include using namespace std; class clockType { public: void setTime(int, int, int); void getTime(int &, int &, int &) const; void

C++ source code
include
#include
using namespace std;
class clockType
{
public:
void setTime(int, int, int);
void getTime(int &, int &, int &) const;
void printTime() const;
void incrementSeconds();
void incrementMinutes();
void incrementHours();
bool equalTime(const clockType&) const;
private:
int hr;
int min;
int sec;
};
int main()
{
clockType myClock;
clockType yourClock;
int hours;
int minutes;
int seconds;
myClock.setTime(5, 4, 30);
cout
myClock.printTime();
cout
cout
yourClock.printTime();
cout
yourClock.setTime(5, 45, 16);
cout
yourClock.printTime();
cout
if (myClock.equalTime(yourClock))
cout
else
cout
cout
cin >> hours >> minutes >> seconds;
cout
myClock.setTime(hours, minutes, seconds);
cout
myClock.printTime();
cout
myClock.incrementSeconds();
cout
myClock.printTime();
cout
myClock.getTime(hours, minutes, seconds);
cout
system("PAUSE");
return 0;
}
void clockType::setTime(int hours, int minutes, int seconds)
{
if (0
hr = hours;
else
hr = 0;
if (0
min = minutes;
else
min = 0;
if (0
sec = seconds;
else
sec = 0;
}
void clockType::getTime(int &hours, int &minutes, int &seconds) const
{
hours = hr;
minutes = min;
seconds = sec;
}
void clockType::printTime() const
{
if (hr
cout
cout
if (min
cout
cout
if (sec
cout
cout
}
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();
}
}
bool clockType::equalTime(const clockType& otherClock) const
{
return(hr == otherClock.hr
&&min == otherClock.min
&&sec == otherClock.sec);
}
 C++ source code include #include using namespace std; class clockType {
Lab to turn in: Add the following to the function main. (1) Declare two clockType objects big Ben and grandfather where the defau big Ben and the constructor with parameters sets the initial data members of grandfather to the time 14:35:59. (2) Print the times of both objects, with labels telli Increment the time of grandfather by 1 second and print the time for grandfather after the increment. It constructor is used to initialize the data members of s, with labels telling which is which

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!