// SPECIFICATION FILE (Time.h) // This file gives the specification of a Time ADT with // action responsibilities and knowledge responsibilities class Time { public: // Action responsibilities void Set( /* in */ int hours, /* in */ int min, /* in */ int seconds ); // Precondition: // 0 <= hours <= 23 && 0 <= minutes <= 59 // && 0 <= seconds <= 59 // Postcondition: // Time is set according to the incoming parameters void Increment(); // Precondition: // The Set function has been invoked at least once // Postcondition: // Time has been advanced by one second, with // 23:59:59 wrapping around to 0:0:0 virtual void Write() const; // Precondition: // The Set function has been invoked at least once // Postcondition: // Time has been output in the form HH:MM:SS bool Equal( /* in */ Time otherTime ) const; // Postcondition: // Function value == true, if this time equals otherTime // == false, otherwise bool LessThan( /* in */ Time otherTime ) const; // Precondition: // This time and otherTime represent times in the same day // Returns: // true, if this time is earlier in the day than otherTime // false, otherwise Time(); // Defualt constructor // Postcondition: Time is set to current system time Time ( /* in */ int hours, /* in */ int minutes, /* in */ int seconds ); // Precondition: // 0 <= hours <= 23 && 0 <= minutes <= 59 // && 0 <= seconds <= 59 // Postcondition: // Time is set according to the incoming parameters // Knowledge responsibilities int Hours() const; // Postcondition: Return value is time int Minutes() const; // Postcondition: Return value is minutes int Seconds() const; // Postcondition: Return value is seconds private: int hrs; int mins; int secs; };