#ifndef TIMES_H #define TIMES_H #include /** * Times in this program are represented by three integers: H, M, & S, representing * the hours, minutes, and seconds, respecitvely. */ struct Time { // Create time objects Time(); // midnight Time (int h, int m, int s); // Access to attributes int getHours() const; int getMinutes() const; int getSeconds() const; // Calculations with time void add (Time delta); Time difference (Time fromTime); /** * Read a time (in the format HH:MM:SS) after skipping any * prior whitepace. */ void read (std::istream& in); /** * Print a time in the format HH:MM:SS (two digits each) */ void print (std::ostream& out) const; /** * Compare two times. Return true iff time1 is earlier than or equal to * time2 */ bool noLaterThan(const Time& time2); /** * Compare two times. Return true iff time1 is equal to * time2 * */ bool equalTo(const Time& time2); // From here on is hidden int secondsSinceMidnight; }; inline std::ostream& operator<< (std::ostream& out, const Time& t) { t.print(out); return out; } inline std::istream& operator>> (std::istream& in, Time& t) { t.read(in); return in; } #endif // TIMES_H