Objectives: Practice implementation of C++ code using inheritance. Problem Description: This program should be implemented using Microsoft Visual C++ 6.0. (1) Develop a Clock class (2) Develop an AlarmClock class (3) Develop a driver program for the AlarmClock class Requirements: (1) Clock class This class displays the computer operating system time using the 24-hour format, e.g., 13:05:11. The display refreshes approximately every second. You may use the Sleep(int msec) function whose prototype is in to pause for one second before refreshing. (2) AlarmClock class This class inherits from the Clock class. The additional data member is the time at which the alarm message ("Time is up") will be displayed for five times. The internal presentation of the time in the class is the number of seconds since midnight of 1/1/1970. The AlarmClock continues to display the system time after the alarm message is displayed. (3) Driver program The driver program allows the user to specify the arguments for the alarm clock. It will utilize the AlarmClock class to demonstrate the functionality of the class. The command line for executing the program is something like this: alarmclock 15:20:30 (This will set the alarm off at 15:20:30.) (4) Adding any utility methods is your decision. Deliverables: (1) A floppy disk that contains .dsw, .dsp, .h and .cpp files; (2) Hardcopies of the .h, .cpp files and the output; (3) An envelope to hold both the floppy disk and the hardcopies.
## Deliverables
References: (1) Sample code for getting command line arguments: int main(int argc, char *argv[]) { cout << "you have entered " << argc << " arguments" << endl; int i; for (i = 0; i < argc; i++) { cout << "argv[" << i << "] is: " << argv[i] << endl; } return 0; } Note that argv[i] is a char *, which points to a NULL-terminated string. If you need to convert such a string into a number, use the function atoi(). See Textbook p.874 for details. (2) About system time System time as the number of seconds since the midnight of 1/1/1970 can be obtained using the time() function. See the example from MSDN below: /* ASCTIME.C: This program places the system time * in the long integer aclock, translates it into the * structure newtime and then converts it to string * form for output, using the asctime function. */ #include #include struct tm *newtime; time_t aclock; void main( void ) { time( &aclock ); /* Get time in seconds */ newtime = localtime( &aclock ); /* Convert time to struct */ /* tm form */ /* Print local time as a string */ printf( "The current date and time are: %s", asctime( newtime ) ); } Output The current date and time are: Sun May 01 20:27:01 1994 (3) Use the asctime() function to extract the time in the hh:mm:ss format for display.
## Platform
any OPERATING SYSTEM, MS WINDOWS 98 OR NEWER. PROGRAM MUST BE WRITTEN BY USING MICROSOFT VISUAL C++ 6.0.