Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3.-Implement a new program that creates a const clocktype object and invoke all the const methods on it. Report the results of compilation and running

3.-Implement a new program that creates a const clocktype object and invoke all the const methods on it. Report the results of compilation and running the program.

image text in transcribedimage text in transcribed
class clockType public: //Place the function prototypes of the functions setTime, //getTime, printTime, incrementSeconds, incrementMinutes, //incrementHours, and equalTime as described earlier, here. clockType (int hours, int minutes, int seconds) ; //Constructor with parameters / /The time is set according to the parameters. / /Postconditions: hr = hours; min = minutes; sec = seconds 11 The constructor checks whether the values of hours, 11 minutes, and seconds are valid. If a value is invalid, 1 1 the default value 0 is assigned. clockType () ; //Default constructor with parameters / /The time is set to 00:00:00. / /Postcondition: hr = 0; min = 0; sec = 0void setTime (int hours, int minutes, int seconds) ; / /Function to set the time / /The time is set according to the parameters / / Postcondition: hr = hours; min = minutes; sec = seconds 11 The function checks whether the values of hours, 11 minutes, and seconds are valid. If a value is invalid, 11 the default value 0 is assigned. void getTime (int& hours, int& minutes, int& seconds) const; / /Function to return the time / / Postcondition: hours = hr; minutes = min; seconds = sec void printTime () const; / /Function to print the time / / Postcondition: Time is printed in the form hh:mm:ss. void incrementSeconds () ; / /Function to increment the time by one second / / Postcondition: The time is incremented by one second. 11 If the before-increment time is 23:59:59, the time 11 is reset to 00:00:00. void incrementMinutes ( ) ; void incrementHours () ; //Function to increment the time by one hour / / Postcondition: The time is incremented by one hour. 11 If the before-increment time is 23:45:53, the time 11 is reset to 00:45:53. bool equalTime (const clockType& otherClock) const; / /Function to compare the two times / /Postcondition: Returns true if this time is equal to 11 otherClock; otherwise, returns false private: int hr; / /stores the hours int min; / /store the minutes int sec; / /store the seconds }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

Develop a complete business case for an idea.

Answered: 1 week ago

Question

Was the media mix the best that could have been achieved?

Answered: 1 week ago