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.h that defines the Date class. It must have 3 private integers to hold the month, day, and year. It also needs the following functions:
Date()Date(int m, int d, int y)Date(Date const & d)~Date()int getDay() const, int getMonth() const, int getYear() constbool setDay(int d), bool setMonth(int m), bool setYear(int y)bool setDate(int m, int d, int y)bool equals(Date const & date) constvoid displayDate() constvoid add(int n) void sub(int n) Date.cpp that implements the above functionality. testDate.cpp to 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
Date.h, Date.cpp, and testDate.cpp. MAKE SURE YOUR NAME IS ON THE TOP OF EACH FILE! Use
jbsartor as the grader and assign4 as
the assignment name (if you choose to take mulligans, use assign4Mulligan).
computer% turnin --submit jbsartor assign4 Date.h Date.cpp testDate.cpp
Date.h Date.cpp testDate.cpp
Implement the following extra methods in your Date class.
Date(string date)readDate()int difference(Date const & date) const