Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5. A clock is used to display time. It shows the hours, minutes, and seconds of a day. You will write a Clock class with

image text in transcribed
5. A clock is used to display time. It shows the hours, minutes, and seconds of a day. You will write a Clock class with the following (partial) interface. class Clock [ public: Clocktint h, int m, int a); void advancetint h, int m, int 5); int untilNextDay(); void print(); private: int hr, min, sec; 3; Private data members: int hr, min, sec; The hours, minutes, and seconds of a day respectively. Hours must be within 023. and minutes and seconds must be within 059. Public constructor: Clock (int h, int: 111, int. 3) ; Creates 21 Clock object where the hours, minutes, and seconds are initialized to the param- eters h. m. and s respectively. You can assume that h 2 0 and 0 S m,s S 59. Public member function: void advance (int 11, int m, int 5) ; Advance the clock by h hours, in minutes. and 5 seconds. If the clock goes beyond 23:59:59, it shall "wrap around" back to 00:00:00. E.g., suppose the clock is 22:33:44, advancing it by 17 hours, 40 minutes, and 52 seconds would make the clock become 16:14:36. You can assume that h 2 0 and 0 5 ms 5 59. Public member function: int untilNextDay () ; Return the number of seconds until mid-night of the next day. E.g., suppose the clock is 22:58:58. The number of seconds until mid-night of the next day is 3662 (equivalent to 1 hour, 1 minute, and 2 seconds). Public member function: void print () ; Prints the clock in the format \"hh:mm:ss". E.g., suppose the clock is 9:08am, the printing shall be . (a) (3%) Implement the constructorClock: :Clock(int h, int rn, int 3). (b) (8%)Implementthememberfunction void Clock: :advance(int h, int m, int 3). (c) (7%) Implement the member function int Clock: :untilNextDay () . (d) (6%) Implement the member function void Clock: :print (l

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

Professional Android 4 Application Development

Authors: Reto Meier

3rd Edition

1118223853, 9781118223857

Students also viewed these Programming questions