Question
Code in c++. IMPORTANT: Code in c++. Implementation of Class function should be in the cpp file. header(.h) file should only contain function headers. You
Code in c++.
IMPORTANT: Code in c++. Implementation of Class function should be in the cpp file. header(.h) file should only contain function headers. You have to make .cpp and .h files for for all the classes and make necessary changes in makefile
Task:
Code in c++.
This question requires you to write code to manipulate dates and perform date arithmetic. Design your application using the following two classes:
class Date{
public:
Date(); // initialize attributes with default values
Date(int,int,int);// if invalid, set default date or set equal to system date
Date(const Date&);
bool inputDate(); /* assign values to Date attributes (cin from user),
return true if valid range of values are input */
bool copyDate(Date&);
bool inputCompleteDate(int,int,int);
Date& getDate() const;
void retrieveDate(int& , int& , int&) const; // retrieve Date attribute values
void showDate() const; // Display Date attribute values
bool isEqual(Date&); // return true if both dates are equal
bool isLeapYear();
// All other relevant methods go here, setter/getter etc
private:
bool validateDate(); // Validate attribute range values methods can also be private
int day;
int month;
int year;
};
________________________________________
class DateCalculator{
public:
int daysBetween(Date& , Date& ); // return days elapsed between two Dates classical example of association
bool isEarlier(Date& D1, Date& D2); /* return true if D1 is earlier
or same as D2 otherwise return false */
// All other relevant methods go here
private:
// All relevant attributes go here
};
The main functional requirements are as follows:
- The program must prompt the user to input two dates in mm dd yyyy format
- The program must validate the dates to make sure it conforms to normal range of values
- The program must verify that the first date is chronologically earlier (or the same as) the second date
- If the above two items are satisfied, the program must compute and display the number of days elapsed between the two dates. Your program must accommodate leap years.
Following should be implemented:
- Deep copy.
- Copy constructor
- Dectructor
- Function overriding
- Initializer List
- Deleting pointers
- Display() and setter/getter
- Make a menu driven code.
- Do not use strings. User char pointers instead
Code in c++.
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