Modifying Time Class to Include Tick Member Function, Lecture notes of Computer Programming

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

2012/2013

Uploaded on 04/27/2013

kid
kid 🇮🇳

4.3

(18)

110 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
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;
};

Partial preview of the text

Download Modifying Time Class to Include Tick Member Function and more Lecture notes Computer Programming in PDF only on Docsity!

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; };