// 1
Fig. 9.8: Time.h 2 // Declaration of class Time. 3 // Member functions defined in Time.cpp. 4 5 // prevent multiple inclusions of header file 6 #ifndef TIME_H 7 #define TIME_H 8 9 // Time abstract data type definition 10 class Time 11 { 12 public: 13 Time( int = 0, int = 0, int = 0 ); // default constructor 14 15 // set functions 16 void setTime( int, int, int ); // set hour, minute, second 17 void setHour( int ); // set hour (after validation) 18 void setMinute( int ); // set minute (after validation) 19 void setSecond( int ); // set second (after validation) 20 21 // get functions 22 int getHour(); // return hour 23 int getMinute(); // return minute 24 int getSecond(); // return second 25 26 void printUniversal(); // output time in universal-time format 27 void printStandard(); // output time in standard-time format 28 private: 29 int hour; // 0 - 23 (24-hour clock format) 30 int minute; // 0 - 59 31 int second; // 0 - 59 32 }; // end class Time 33 34 #endif |