Question: Design a class called Clock in C++. It must be seperated into Main.cpp, Time.cpp and Time.h. This class needs three member variables hours, minutes, and
Design a class called Clock in C++. It must be seperated into Main.cpp, Time.cpp and Time.h. This class needs three member variables hours, minutes, and seconds. The class should have a default constructor and a constructor that accepts hours, minutes, and seconds. It should also have member functions for storing and retrieving the hours, minutes and seconds. The class should also have the following overloaded operators:
+ Addition operator. When two clock objects are added together, the overloaded + operator should return the sum of the two object's hours, minutes, and seconds, converted into valid hours, minutes and seconds.
- Subtraction operator. When one clock object is subtracted from another clock object, the overloaded - operator should return the difference of the two object's hours, minutes, and seconds, converted into valid hours, minutes and seconds.
++ Prefix and postfix increment operators. These operators should increment the number of hours stored in the object. When incremented, the number of hours may need to be recalculated.
-- Prefix and postfix decrement operators. These operators should decrement the number of hours stored in the object. When decremented, the number of hours may need to be recalculated.
> Greater than - returns true if the first time is greater than the second, otherwise returns false.
Please have your program ask the user for two different times in hours (12 hour clock), minutes, and seconds. Then add the two times, subtract the two times, increment the first time, both pre and post increment, and decrement the second time, both pre and post decrement, and compare the two times using .
Below is an example of what the output should look like:

lease enter the hour: 12 Please enter the ninute 59 Please enter the seconde: 59 The firat tine that you entered vas 12 o'clock 59 ninutes &59 seconds or 12:59.59 Please enter the second hour: 5 Please enter the second ninutc: 10 Please enter the second seconds 10 The second tine that you entered was 5 o'clock 18 ninutes & 18 seconds or 5:18. The two tines added together is 6 o'clock. 18 ninutes & 9 seconds r 6:18.9 ine 1 ninus tine 2 is o'clock 49 ninutes & 19 seconds or ?:49-49 Postincrenent tine1 and add to tine2 60'clock 10 ninutes &9 seconds ine 1 is nou 1 o'clock 59 ninutes 59 seconds or 1:59.59 reincrement tine1 and add to tine2 8 o'clock 10 ninutes & 9 seconds Tine 1 is nou 2 o'clock 59 ninutes 59 seconds or 2:59.59 Postdecrenent tine2 and add to tine1 8 o'clock 18 ninutes & 9 seconds Tine 2 is now 4 o'clock 10 ninutes 18 seconde or 4:10.10 Predecrenent tine2 and add to tinet 6 o'clock 18 ninutes & 9 seconda Tine 2 is now 3 o'clook 10 ninutes 10 seconds or 3:10.10 IS Tine1 Tine2? True IS Tinel line2? False Press Enter to return to Quincy
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
