Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Clock Program Please do exactly as follows in C++ Programming Language Building the Class For this assignment, you will create a clock that expresses time
Clock Program
Please do exactly as follows in C++ Programming Language
Building the Class For this assignment, you will create a clock that expresses time in hours, minutes and seconds; however, the clas will only stores seconds passed midnight. For example, 1:30:00 PM translates to 48, 600 seconds passed midnight. Th general formula for calculating seconds passed midnight is S=hr 3600 mn 60 + sd where ir ishur 23), n is minutes (0-59) and sd is seconds (0-59) The class Clock should be stored in the header file "Clock.h and should consist of a Private int ficld named seconds a Public default constructor that assigns 0 (midnight) to seconds. Public overloaded constructor that takes an int as a parameter named seconds. It assigns seconds to the seconds fiek only if it is between 0 and 86399 inclusively; ot herwise, it assigns 0 to the seconds field. o Public copy constructor that performs a shallow copy a Public overloaded assignment operator that performs a shallow copy a Public constant get method for the hour. It should return the hour represented by seconds in 24-hour format (0-23) o Public constant get method for the minute. It should return the minute represented by seconds in 21-hour forma (0-59) a Public constant get method for the second. It should return the second represented by seconds in 24-hour forma (0-59) a Public set method for hour. If the parameter is between 0 and 23 inclusively, it should adjust seconds to the new hou while maintaining the minute and second; otherwise, does nothing. a Public set method for minute. If the parameter is between 0 and 59 inchusively, it should adjust seconds to the nes minute while maintaining the hour and second; otherwise, it does nothing. a Public set method for second. If the parameter is between 0 and 59 inclusively, it should adjust seconds to the nes second while maintaiing the hour and minute; otherwise, it does nothing. a Public void method named Tick that takes no parameters. It increments seconds by 1. Recall that seconds is cyclic o Public string constant met hod named ToString) that takes no parameters. It shonld return a string of the followin format: hour: minute: second where hour,minute,second is the time represented by seconds in 24-hour format. Implementing the Class In the main function, create two Clock objects and assign them random times, one using the overloaded constructo and the other with the set methods. Last, simultaneously display the count up of an hour for each object. The followin is a portion example of a possible outp ut 16:19:05 04:00:05 16:19:06 04:00:06 16:19:07 04:00:07 16:19:08 04:00:08 16:19:09 04:00:09 16:19:10 04:00:10 16:19:11 04:00:11 16:19:12 04:00:12Step 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