// finction definitions for class Time // mikhail nesterenko // 10/15/99 #include #include "time.h" // initializes the object of class Time::Time(int h, int m, int s) { hour = (h >= 0 && h < 24) ? h : 0 ; // hor should be under 24 // or 0 is assigned minute = (m >= 0 && m < 60) ? m : 0 ; // range is acceptable or 0 second = (s >= 0 && s < 60) ? s : 0 ; // same here } // prints time in military format void Time::printMilitary() const { cout << (hour < 10 ? "0" : "") << hour << ":" << (minute < 10 ? "0" : "") << minute << ":" << (second < 10 ? "0" : "") << second; } // prints time in standard format void Time::printStandard() const { cout << (( hour == 0 || hour == 12 ) ? 12 : hour % 12 ) << ":" << (minute < 10 ? "0" : "") << minute << (hour < 12 ? "am" : "pm" ); }