Question
The purpose of this assignment is to give you practice using constructors and destructors. Program Requirements: Create a Date class containing: 3 pointer to int
The purpose of this assignment is to give you practice using constructors and destructors.
Program Requirements:
Create a Date class containing:
3 pointer to int data members
- int* month; - int* day; - int* year;
5 constructors
a destructor
a print() function
a print_long() function
You may use these two named constants:
- const string Months[13] = {"","January","February","March","April","May","June","July","August",
"September","October","November","December"};
- const int CurrentYear = 2018;
You may use this one global variable:
int DaysPerMonth[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
Use the following main():
int main() { Date today; Date todayCopy(today); Date feb2815(2,28,15); // assume the year is 2015 Date assignmentDueDate(3,6); // assume the year is the Current Year Date feb2895("02-28-95"); // assume the year is 1995 Date newYearsDay("01/01/18"); // assume the year is 2018 Date idesOfMarch(74); // assume the year is the Current Year Date eoy(365); // assume the year is the Current Year cout << "Today: "; today.print(); cout << "Today: "; todayCopy.print(); cout << "feb2815: "; feb2815.print(); cout << "Assignment due date: "; assignmentDueDate.print(); cout << "feb2895: "; feb2895.print(); cout << "New Years Day: "; newYearsDay.print(); cout << "Ides of March: "; idesOfMarch.print(); cout << "Last Day of Year: "; eoy.print(); cout << "Today: "; today.print_long(); cout << "Today: "; todayCopy.print_long(); cout << "feb2815: "; feb2815.print_long(); cout << "Assignment due date: "; assignmentDueDate.print_long(); cout << "feb2895: "; feb2895.print_long(); cout << "New Years Day: "; newYearsDay.print_long(); cout << "Ides of March: "; idesOfMarch.print_long(); cout << "Last Day of Year: "; eoy.print_long(); }
Assumptions:
Assume any 2-digit year that is < 50 represents a year that is >= 2000 and any 2-digit year that is >= 50 represents a year that is < 2000.
The feb2895 and newYearsDay objects are created using the same constructor.
The feb2815 and assignmentDueDate objects are created using the same constructor.
The constructor with one int argument creates a Date using the Current Year. The int argument is the day number of the year.
Output should look like this:
Today: 01/02/18 <=== This will be the current date Today: 01/02/18 <=== This will be the current date feb2815: 02/28/15 Assignment due date: 03/06/18 feb2895: 02/28/95 New Years Day: 01/01/18 Ides of March: 03/15/18 Last Day of Year: 12/31/18 Today: January 2, 2018 <=== This will be the current date Today: January 2, 2018 <=== This will be the current date feb2815: February 28, 2015 Assignment due date: March 6, 2018 feb2895: February 28, 1995 New Years Day: January 1, 2018 Ides of March: March 15, 2018 Last Day of Year: December 31, 2018
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started