// date.h // ---------------------------------------------------------------------- // declares class Date // Do not modify this file. // // CSE 143 // Homework 2, 3 // http://www.cs.washington.edu/education/courses/143/00su/homework/ // 25 Jun 2000; Man-Hing Wong, Ken Yasuhara #ifndef _DATE_H_ #define _DATE_H_ class Date { public: // // constructors, verification // // creates a date that is invalid Date(); // allows construction of invalid dates Date(int newMonth, int newDay, int newYear); // returns true iff 1 <= month <= 12, // and 1 <= day <= max number of days in month, // and year > 0 bool isValid(); // // accessors // // getYear() returns year in four-digit format int getMonth(); int getDay(); int getYear(); // // methods // // return a positive number if this date is earlier than otherDay; // return 0 if other is the same day; // return a negative number if this date is NOT earlier than otherDay; // (An invalid date comes before all valid ones, and on the same day // as all other invalid dates.) int compare(Date otherDay); // increment date by numDays days; // should yield invalid Date only by running off the end of the // year, e.g. 1/30 plus 3 days should yield the valid Date 2/2, not // the invalid 1/33 // Precondition: 0 <= numDays void addDays(int numDays); // return how many days (absolute value) between this date and given date int dayDifference(Date d); // print this date void printDate(); // return number of days in given month of given year, // taking leap years into account; // mostly used internally, e.g. by addDays() int daysInMonth(int month, int year); private: // // member data // int month; int day; int year; }; #endif