// CS2310 Chapter 11 Excise // Taken from textbook p623 - 6 // // Add new member functions NotEqual, LessOrEqual, GreaterThan, // and GreaterOrEqual to the TimeType class. // //****************************************************************** // SPECIFICATION FILE (timetyp2.h) // // (This is for the 2nd version of the TimeType class in Chap. 11. // It includes two class constructors.) // // This file gives the specification // of a TimeType abstract data type //****************************************************************** class TimeType { public: void Set( /* 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 void Increment(); // Postcondition: // Time has been advanced by one second, with // 23:59:59 wrapping around to 0:0:0 void Write() const; // Postcondition: // Time has been output in the form HH:MM:SS int GetHours() const; // Postcondition: // Return the value of hours stored in this object int GetMinutes() const; // Postcondition: // Return the value of minutes stored in this object int GetSeconds() const; // Postcondition: // Return the value of seconds stored in this object bool Equal( /* in */ TimeType otherTime ) const; // Postcondition: // Function value == true, if this time equals otherTime // == false, otherwise bool LessThan( /* in */ TimeType otherTime ) const; // Precondition: // This time and otherTime represent times in the // same day // Postcondition: // Function value == true, if this time is earlier // in the day than otherTime // == false, otherwise bool NotEqual( /* in */ TimeType otherTime ) const; // Postcondition: // Function value == true, if this time does not // equal otherTime // == false, otherwise bool LessOrEqual( /* in */ TimeType otherTime ) const; // Precondition: // This time and otherTime represent times in the // same day // Postcondition: // Function value == true, if this time is earlier // in the day than otherTime // or equal to otherTime // == false, otherwise bool GreaterThan( /* in */ TimeType otherTime ) const; // Precondition: // This time and otherTime represent times in the // same day // Postcondition: // Function value == true, if this time is later // in the day than otherTime // == false, otherwise bool GreaterOrEqual( /* in */ TimeType otherTime ) const; // Precondition: // This time and otherTime represent times in the // same day // Postcondition: // Function value == true, if this time is later // in the day than otherTime // or equal to otherTime // == false, otherwise TimeType( /* in */ int initHrs, /* in */ int initMins, /* in */ int initSecs ); // Precondition: // 0 <= initHrs <= 23 && 0 <= initMins <= 59 // && 0 <= initSecs <= 59 // Postcondition: // Class object is constructed // && Time is set according to the incoming parameters TimeType(); // Postcondition: // Class object is constructed && Time is 0:0:0 private: int hrs; int mins; int secs; };