Date setter/getter program

So my problem is I have a really bad professor that isn't really teaching me any code and she assigns this program when I really have no knowledge of c++..
If someone could just point me in the direction of how to start a class and the getters/setters I would greatly appreciate it. I think I can figure out the most of the rest.. Thanks for your help!

Here are my instructions....

Design and implement a class to keep track of a date using the requirements in the attached document. Write a test program (a separate cpp file that includes the class file) that tests each of the member functions to verify they work correctly.

The class definition and implementation can be in the same file, but do not implement the functions inline. If they are implemented inline that will result in a 10 point reduction of the grade.


here is what the attached document says....


Date Class Requirements

Class to store dates will have.
• 3 data members to store the month, day, and year (4 digit)
• Function members to perform operations on a date
o Default constructor
o Constructor that takes a date as parameters
 Make sure the date entered is a valid date
o Setters:
 Set the date
 Set the month
 Set the day
 Set the year
o Getters:
 Get the date (getter)
 Get the day
 Get the month
 Get the year
o Test if a year is a leap year
 Note: Not all centuries are leap years; only those that are evenly divisible by 400 are leap years. All others are not.
o Return the number of days in the month (Example: If the date is 3/12/2012, the number of days to be returned is 31 because there are 31 days in March.)
o Return the number of days passed in the year. (Example: If the date is 3/18/2002, the number of days passed in the year is 77. Note that the number of days returned also includes the current day.)
o Return the number of days remaining in the year (Example is the date is 3/18/2002, the number of days remaining in the year is 288.)
o Print the date (in format mm/dd/yyyy)
o Print the date with the month in text format

NOTE: The constructor and the set date function member should make sure the date is a valid date (1/1/1900 or later, a valid month, and a day that would be in that month).
Use switch statements rather than a bunch of if statements whenever the condition relies on the month!
This should help you with all of your needs: http://www.cplusplus.com/doc/tutorial/
Topic archived. No new replies allowed.