Write a C++ class named Date having three data members:
day
month
year
Your class must have:
A default and parameterized constructor. (use the following default date 2000-01-01)
A function called setDate which takes 3 valid values for day, month, and year (Display an error message to the user when the given values are invalid).
3 functions getDay(), getMonth(), and getYear() .
4.Overloaded << operator to display the date in the following format (YYYY-MM-DD)
Overloaded >> operator to read three values for date, month, and
Overloaded ++ operator to add a day to the current date
Overloaded - - operator to subtract a day from the current date
8. Overloaded logical operators: ( = = , != , > , and < ) Notes:
· While adding and subtracting a day (Auto-increment and auto-decrement) keep in mind to adjust the date (e.g. adding one day to 2019-12-31 will give 2020-01-01).
The result of a logical operation is bool (true or false).
Use the following main function to test your code:
#include "Date.h" #include using namespace std; int main()
{
Date date1(31 , 1, 2019);
Date date2(1 , 3 , 2019);
Date date3(15 , 4 , 2019);
Date date4(15, 4, 2019); Date date5;
cout << "date1 :";
cout << "Day =" << date1.getDay();
cout << " , Month = " << date1.getMonth();
cout << " , Year = " << date1.getYear() << endl; cout << "date1 : " << date1 << endl;
cout << "date2 : " << date2 << endl; cout << "date3 : " << date3 << endl; cout << "date4 : " << date4 << endl; if (date1 == date2)
cout << "date1 is equal to date2" << endl; if (date1 != date2)
cout << "date1 is not equal to date2" << endl; if (date3 == date4)
cout << "date3 is equal to date4" << endl; if (date3 != date4)
cout << "date3 is not equal to date4" << endl; if (date1 < date2)
cout << "date1 is before date2" << endl; if (date3 > date1)
cout << "date3 is after date1" << endl;
cout << "date1 before auto-increment:" << date1 << endl; date1++;
cout << "date1 after auto-increment:" << date1 << endl; cout << "date2 before auto-decrement:" << date2 << endl; date2--;
cout << "date2 after auto-decrement:" << date2 << endl;
cin >> date5;
cout << "date5 :" << date5 << endl;
date1.setDate(1, 12, 2020);
cout << "date1 : " << date1 << endl; date1.setDate(29, 2, 2019); //invalid day cout << "date1 : " << date1 << endl; return 0;
}
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of