
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Instructions on how to modify the time class in c++ to include a tick member function that increments the time stored in a time object by one second. The document also includes a driver program that tests the tick member function in a loop and prints the time in standard format during each iteration to illustrate its correctness. The cases tested include incrementing into the next minute, hour, and day.
Typology: Lecture notes
1 / 1
This page cannot be seen from the preview
Don't miss anything!

Question 1
Modify the Time class to include a tick member function that increments the time stored in a Time object by one second. The Time object should always remain in a consistent state. Write a driver program that tests the tick member function in a loop that prints the time in standard format during each iteration of the loop to illustrate that the tick member function works correctly. Be sure to test the following cases: a) Incrementing into the next minute b) Incrementing into the next hour. c) Incrementing into the next day (i.e., 11:59:59 PM to 12:00:00 AM).
class Time { public: Time( ); void setTime( int, int, int ); void printMilitary( ) void printStandard( ); private: int hour; int minute; int second; };