Inheritance &
Derived Classes Lab
Professor Domanski
Given the following class Time.h -
Design a class called MilTime
that is derived from the Time class. The MilTime class should
convert time in military (24-hour) format to the standard (AM/PM) time format
used by the Time class. The class should
have the following member variables:
milHours Contains the hour in 24 hour format. 1:00PM would be stored as 1300 hours; 4:30PM would be stored as 1630
milSeconds Contains the seconds in standard format.
The MilTime class should have the following member functions:
Constructor should accept parameters for the hour and the seconds in military format. The time should then be converted to standard time and stored in the hour, min, and sec variables of the Time class.
setTime Accepts parameters to be stored in the milHour and milSeconds variables. The time should then be converted to standard time and stored in the hour, min and sec variables of the Time class.
getHour Returns the hour in military format.
getStandHr Returns the hour in standard format.
Create a simple GUI that the user uses to enter a time in military format. The GUI should then display the time in both
military and standard format.
Input Validation The MilTime class should not accept hours greater than 2359, or less than zero. It should not accept seconds greater than 59 or less than zero. Feel free to add validation code to the classes anywhere you think its needed.
Extra Credit Design another class called TimeClock, which is derived from the MilTime class (above). The class allows the programmer to pass two different times to it: a starting time and an ending time. The class should have a member function that returns the amount of time elapsed between the two times. For example, if the starting time is 900 hours (9:00 AM), and the ending time is 1300 hours (1:00 PM), the elapsed time is 4 hours. Enhance your simple GUI above to allow the user to enter a starting time and an ending time (both in military format), and your program will output the elapsed time (in military format) to a text box on the GUI.
Input Validation The class should not accept hours greater than 2359 or less than zero.