//****************************************************************** // SPECIFICATION FILE (timetyp1.h) // // (This is for the first version of the TimeType class in Chap. 11) // // This file gives the specification // of a TimeType abstract data type //****************************************************************** #ifndef TIMETYP8_H #define TIMETYP8_H //#include using namespace std; //class TimeType; class TimeType { private: int hrs; int mins; int secs; int convertedSeconds; int remainder_hrs; int remainder_mins; public: //**************************************** TimeType(){} // constructor ~TimeType(){} // destructor //TimeType(const TimeType &); // copy constructor //use default copy constructor // to and from sec format int ToSec();//Andre wrote function def below class void FromSec(int &Time1);//Andre wrote function def below class // conversion constructor //TimeType(int & Time1); //Andre overload << and >> operators friend ostream &operator<<(ostream&, TimeType&); friend istream &operator>>(istream&, TimeType&); //Andre overload == operator bool operator==(const TimeType&); //Ander overload ++ operator prefix and postfix TimeType operator ++ (); TimeType operator ++ (int); //Andre overload < and > operators bool operator < (const TimeType&); bool operator > (const TimeType&); //Andre overload - operator TimeType operator - (const TimeType&); //Andre set function void Set (int hours, int minutes, int seconds); TimeType(int Time1) { hrs = (Time1)/(3600); remainder_hrs = (Time1) % (3600); mins = (remainder_hrs)/ (60); remainder_mins = (remainder_hrs) % (60); secs = remainder_mins; // return *this; } }; #endif //Overloaded << operator ostream &operator<<(ostream &strm, TimeType &obj) { strm << obj.hrs <<" : "<< obj.mins <<" : "<< obj.secs< operator bool TimeType::operator > (const TimeType &right) { bool status; if (hrs > right.hrs) status = true; else if (mins > right.mins) status = true; else if (secs > right.secs) status = true; else status = false; return status; } //Overloaded - operator TimeType TimeType::operator-(const TimeType &right) { TimeType temp; temp.hrs = hrs - right.hrs; temp.mins = mins - right.mins; temp.secs = secs - right.secs; return temp; } void TimeType::Set(int hours, int minutes, int seconds) { hrs = hours; mins = minutes; secs = seconds; } int TimeType::ToSec() { convertedSeconds = (hrs)*(3600) + (mins)*(60) + (secs); return convertedSeconds; } void TimeType::FromSec(int &Time1) { }