Implement the class Tiktok discussed below. You may assume both iostream and string libraries are included, youmay not use any other libraries. There are 60 seconds in a minute, 3600 seconds in an hour, 60 minutes in an hour.The 24-hour clock convention goes from 0:0:0 to 23:59:59. Read everything before starting that way you get abetter sense on what member variables you need and how you want to implement the member functions. Notethat what we expect to see in the console output is not necessarily what we may want to store as member variables.
It may be useful to recall that the modulus operator “%” can be used to obtain the remainder of integer division,also the “+” operator may be used to concatenate strings, and the function std::to_string(int) takes an integer andreturns the string equivalent of that integer, presumably for concatenating a string with an integer.
Implement the default constructor which sets the initial state of Tiktok to correspond to time 0:00:00 in 24-hourclock convention (or 12:00:00 AM 12-hour clock convention).
addSeconds adds the number of seconds passed into the function to Tiktok. If the amount of seconds to add isnegative do nothing. There is no upper limit to the amount of seconds that can be added.
addMinutes adds the number of minutes passed into the function to Tiktok. If the amount of minutes to add isnegative do nothing. There is no upper limit to the amount of minutes that can be added.
addHours adds the number of hours passed into the function to Tiktok. If the amount of hours to add isnegative do nothing. There is no upper limit to the amount of hours that can be added.
display24 prints to the console the time stored in Tiktok using 24-hour convention; with the following format:XX:XX:XX, followed by a newline.
display12 prints to the console the time stored in Tiktok using 12-hour convention. It will print AM or PMappropriately; with the following format XX:XX:XX XM, followed by a newline
Below is the class definition for Tiktok, presumably in some header file. After planning out your design declare yourmember variables in the private field of the class.
class Tiktok { public: Tiktok(); void addSeconds(int s); void addMinutes(int m); void addHours(int h); void display24() const; void display12() const; private: //TODO: Declare any member variables you think you will need.
Below is example usage for Tiktok :
void main() { Tiktok tt; // Declare an instance of Tiktok tt.addHours(48); tt.display12();// 12:0:0 AM tt.display24();// 0:0:0 cout << endl tt.addSeconds(60);tt.display12();// 1:0:0 AMtt.display24();// 1:0:0cout << endl; tt.addHours(10);tt.addMinutes(59);tt.addSeconds(59);tt.display12();// 11:59:59 AMtt.display24();// 11:59:59cout << endl; tt.addSeconds(1);tt.display12();// 12:0:0 PMtt.display24();// 12:0:0cout << endl; tt.addSeconds(11 * 3600 + 12 * 60 + 8); //11hr*3600s/hr + 12m*60s/m + 8s = 40328stt.display12();// 11:12:8 PMtt.display24();// 23:12:8cout << endl; tt.addMinutes(47);tt.display12();// 11:59:8 PMtt.display24();// 23:59:8cout << endl; tt.addSeconds(52);tt.display12();// 12:0:0 AMtt.display24();// 0:0:0cout << endl; } Implement the member functions of Tiktok below, assume this being done in a separate source file. Be as neat andsyntactically correct as possible. a) Constructor: b) addSeconds: c) addMinutes: d) addHours: e) display24: f) display12:
