Question: Create a class called Time and then write a driver program to test your class by creating some objects and performing various operations. Your program

Create a class called Time and then write a driver program to test your class by creating some objects and performing various operations. Your program must have at least three files: a Time header file (Time.h), a Time implementation file (Time.cpp), and an application file (TimeDriver.cpp). The class has only two int data members hour and minute, with the hour defaults to 0 and the minute defaults to 0 (i.e., the constructor has two default arguments, hour and then minute in that order; note that the default time is 00:00 or 12:00 AM). The hour must be between 0 and 23 and the minute must be between 0 and 59 so validation is needed. Provide the following public member functions:

Constructor (two default parameters); must verify that hour is between 0 and 23 and default to 0 if needed; must verify that minute is between 0 and 59 and default to 0 if needed.

Time(int h = 0, int m = 0);

Setting the hour (must verify that the value is between 0 and 23 and keep current hour if applicable). void setHour(int h);

Setting the minute (must verify that the value is between 0 and 59 and keep current minute if applicable). void setMinute(int m);

Returning the hour. int getHour();

Returning the minute. int getMinute();

Printing the time in AM/PM format (like 1:05 AM, but not 1:5 AM). void print();

Include and use an array of Time objects and a Time pointer in your program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!