Question: Complete clockType.h and clockType.cpp, and write a main() to try as many member functions of clockType as possible. Run your program and attach the output.

Complete clockType.h and clockType.cpp, and write a main() to try as many member functions of clockType as possible. Run your program and attach the output.

//main.cpp #include "clockType.h" #include using namespace std;

int main() { clockType myClock, yourClock(10, 8, 43);

myClock.setTime(9, 48, 30); //yourClock.setTime(9, 52, 50);

cout << "The current time is "; myClock.printTime(); cout << endl;

cout << "Your Clock time is "; yourClock.printTime(); cout << endl;

if (myClock.equalTime(yourClock) == true) cout << "They are the same. "; else cout << "They are different. ";

return 0; }

//clockType.h #ifndef CLOCKTPE_H #define CLOCKTPE_H

#include using namespace std;

class clockType { private: int hr, mint, sec; public: void setTime(int h, int m, int s); void setHour(int h) {hr = h;} // setmin // setsec int getHour() {return hr;} // return min // return sec void getTime(int & h, int & m, int & s); void printTime(); void incrementSec(); // incrementMin(); // incrementHour(); bool equalTime(const clockType &) const; // constructor clockType(); //default constructor clockType(int, int, int); //destructor ~clockType(){cout << "bye" << endl;} };

#endif // CLOCKTPE_H

//clockType.cpp #include "clockType.h" #include using namespace std;

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

clockType::clockType(int h, int m, int s) { hr = h; mint = m; sec = s; }

void clockType::setTime(int h, int m, int s) { if (h >= 0 && h < 24) hr = h; else hr = 0; mint = m; // check m is between 0 and 59 sec = s; // check s is between 0 and 59 }

void clockType::getTime(int & h, int & m, int & s) { h = hr; m = mint; s = sec; }

//printTime() 00:00:00

void clockType::incrementSec() { sec++; if (sec > 59) { //incrementMin(); //mint++; sec = 0; } }

// incrementMin()

// incrementHour()

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

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

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

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

//ClockType.h

#ifndef CLOCKTYPE_H

#define CLOCKTYPE_H

class clockType

{

private:

int hr;

int minu;

int sec;

public:

void setTime(int hours, int minutes, int seconds);

void setH(int hours);

void setM(int minutes);

void setS(int seconds);

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

int getH();

int getM();

int getS();

void printTime();

void incrementS();

void incrementM();

void incrementH();

clockType(); //default constructor

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

~clockType(){} //destructor

bool equalTime(const clockType & otherClock);

};

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!