#ifndef CS101_CLASS_DATE #define CS101_CLASS_DATE #include using namespace std; class Date { public: // default constructor: creates day of form month/day/year Date(int month = 9, int day = 14, int year = 1752); // inspector getMonth(): returns the month associated with the date int getMonth() const; // inspector getDay(): returns the day associated with the date int getDay() const; // inspector getYear(): returns the year associated with the date int getYear() const; // mutator setMonth(): sets the month associated with the date, if // an invalid month is requested, an error message is generated and // 1 is used. void setMonth(int month); // mutator setDay(): sets the day associated with the date, if // an invalid day is requested, an error message is generated and // 1 is used void setDay(int day); // mutator setYear(): sets the year associated with the date, if // an invalid year is requested, an error message is generated and // 2001 is used void setYear(int year); // mutator extract(): sets the date using the representation extracted // from input stream sin. The representation has form month/day/year. // If an invalid month, day, or year is supplied, an error message is // generated and the date 1/1/2001 is used. void extract(istream &sin); // operator ++: changes the representation of the invoking object to // the immediately successive date. The invoking object is returned. Date& operator ++ (void); // operator ==: returns true if the source represents the date as the // invoking object bool operator == (const Date& source) const; // facilitator insert(): displays a representation of the date to // stream sout. The representation has form month/day/year. void insert(ostream &sout) const; private: int thisMonth; // represents the month of our date int thisDay; // represents the day of our date int thisYear; // represents the year of our date }; // auxiliary operators // operator >>: extracts a date of form month/day/year from sin and assigns // it to target. The operator is supplied as a client courtesy, The operator // makes use of date member function extract istream& operator >> (istream &sin, Date &target); // operator <<: inserts the date to sout with form month/day/year. The // operator is supplied as a client courtesy, The operator makes use of // date member function insert ostream& operator << (ostream &sout, const Date &source); // operator +: returns the date that is nbrDays days after dateOfInterest, // where nbrDays is at least 0 Date operator + (const Date &dateOfInterest, int nbrDays); // isLeapYear(): returns true if y is a leap year; otherwise, returns // false bool isLeapYear(int y); #endif