Tuesday, February 23th at NOON
For this project you will implement a Date class similar to the date class found in the C++ Standard Library. Your date must be able to represent any valid date from January 1, 1900 into the future accepting only valid input (if invalid, set to default Jan 1, 1900). For example, February 29th is a valid date for any leap year. Leap years are years that are divisible by 4, with one exception. If the year is divisible by 100 and not by 400 (like 2100), then it is not a leap year. (e.g. 2004 was, 2008 was, 1900 was not, 2100 will not be, 2400 will be, and so on).
Date.hthat defines the Date class. It must have 3 private integers to hold the month, day, and year. It also needs the following functions:
Date(int m, int d, int y)
Date(Date const & d)
int getDay() const, int getMonth() const, int getYear() const
bool setDay(int d), bool setMonth(int m), bool setYear(int y)
bool setDate(int m, int d, int y)
bool equals(Date const & date) const
void displayDate() const
void add(int n)
void sub(int n)
Date.cppthat implements the above functionality.
testDate.cppto test all functionality of your Date class. Of course I will provide my own testDate to test your Date class when I grade, but you should convince yourself that your code works before turning it in. You can use a Makefile to compile all 3 files, but this time you do not have to turn it in.
computer% g++ -Wall -Werror -c Date.cpp computer% g++ -Wall -Werror -c testDate.cpp computer% g++ -Wall -Werror -o testDate Date.o testDate.o computer% ./testDate
testDate.cpp. MAKE SURE YOUR NAME IS ON THE TOP OF EACH FILE! Use
jbsartoras the grader and
assign4as the assignment name (if you choose to take mulligans, use
computer% turnin --submit jbsartor assign4 Date.h Date.cpp testDate.cpp
Implement the following extra methods in your Date class.
int difference(Date const & date) const