I have an assignment and have got most of the first part do. There is a part however, I am having troubles with..I am not sure what she is getting across for the part asking to make a Date::setDate().....not sure what to put in it...
any way here is the long ass assignment
The Date class
This class has three member variables
month – an integer in the range of 1-12
day – an integer within the range of the allowed month
year – an integer in the range of 0-3000
This class has the following member functions. These are the actual function prototypes. You are to write the function implementation for each function.
Date();
This is the default constructor. It is to set day to 1, month to 1, and year to 2000.
Date(int,int,int=0);
This is another constructor. The parameters are in the following order: month, day, year. Setting the year to 0 identifies that this date does not need a year.
int getDay();
This is the get function for day.
int getMonth();
This is the get function for month.
int getYear();
This is the get function for year.
void setDay(int);
This is the set function for day. It is to verify the day sent is within the correct range for the current month. If it is, set it to the sent value. If it is not within the correct range for the month, set it to 1. I have provided the function implementation for you. You may use it if you would like. Click here to get the file.
void setMonth(int);
This is the set function for month. It is to verify the month sent is between 1-12. If it is, set it to the sent value. If it is not within the correct range for the month, set it to 1.
void setYear(int);
This is the set function for year. It is to verify the year sent is between 0-3000. If it is, set it to the sent value. If it is not within the correct range for the year, set it to 0.
void setDate(int, int, int=0);
This is a set function for an entire date. It is to call the appropriate set functions for month, day, and year. It is important that you set the month and the year before setting the day. Setting the year to 0 identifies that this date does not need a year.
void printShort(ostream&);
This function is to print the Date using the following format: month/day/year
Example: 3/28/2009
If the year is 0, print it using the following format:
month/day
Example: 12/25
It is to print the Date to the output stream sent to the function.
void printLong(ostream&);
This function is to print the Date using the following format:
MonthName day, year
Example: March 28, 2009
If the year is 0, print it using the following format:
MonthName day
Example: December 25
It is to print the Date to the output stream sent to the function.
The Holiday class
This class has two member variables
date – a Date that contains the date of the holiday
name – a string that contains the name of the holiday
This class has the following member functions. These are the actual function prototypes. You are to write the function implementation for each function.
Holiday(string,int,int,int=0);
This is a constructor. The parameters are in the order name, month, day, year.
Holiday(string, Date);
This is a constructor. The parameters are in the order name, date.
void print(ostream&);
This function prints out the Holiday using the following format:
name monthName day, year.
Example: Thanksgiving November 24, 2011
if year is 0 the function is to print the Holiday using the following format:
name monthName day.
Example: Christmas December 25
It is to print the Date to the output stream sent to the function.
void setDate(int,int,int=0);
This function calls the correct Date function that sets the date member variable to the values sent.
void setName(string);
This is the set function for name.
Date getDate();
This is accessor function for date.
string getName();
This is the accessor function for name.
The file testMain.cpp is an application that tests each function in the Date and Holiday classes. Add this file to your project then code the classes. I suggest you write the member functions in the order listed below. Test each member function as you complete it. The code in main is all commented out. To test each function, move the opening comment tag (/*) down to the next section.
I was thinking something like this...
1 2 3 4 5
|
void Date::setDate(int m, int d, int y){
Date.setMonth(m)=month;
setYear(y);
setDay(d);
| |
not sure what she wants and I know I am doing it wrong....Anyway if you got through all that, any help would be greatly appreciated.