We write, we don’t plagiarise! Every answer is different no matter how many orders we get for the same assignment. Your answer will be 100% plagiarism-free, custom written, unique and different from every other student.
I agree to receive phone calls from you at night in case of emergency
Please share your assignment brief and supporting material (if any) via email here at: support@instaresearch.co.uk after completing this order process.
No Plagiarism Guarantee - 100% Custom Written
In this paper, the current date and the age calculated using the birthdate and the current date and you are required to display the local date time created as birthdate and a header file age.h with code to prevent multiple inclusion. Also, provide a text file task_2_3.txt containing compilation messages and sample runs and include the code for class DateTime in age.h and age.cpp
Derive class Age from class DateTime such that Age::display() will display birthdate in local date time format using values from the parameters, the current time and the age.
class Age : public DateTime {
public:
// Date supplied is birth date, should be earlier than current date
Age(int y, int m, int d, int h = 0, int min = 0, int s = 0);
void display();
protected:
struct tm Astruct; // tm for current time private:
string int_2_string(int);
void error_action();
string age;
};
string Age::int_2_string(int n){
ostringstream outstr;
if (n > 100000){
outstr << (n - 100000);
return outstr.str() + " days old.";
} else if (n > 1000){
outstr << (n - 1000);
return outstr.str() + " months old.";
} else {
outstr << n;
return outstr.str() + " years old.";
}
void Age::error_action(){
cout << "Birthday must be in the past!n";
exit(EXIT_FAILURE);
Implement
Validate parameter values the same way as in class DateTime.
When calculating age, the unit can be day, month or year. To differentiate the units, add 1,000 to age in months, add 100,000 to age in days. When passed to int_2_string, we can convert the age to proper values and units.
Display the local date time created as birthdate; the current date and the age calculated using the birthdate and the current date.
You have to provide:
a header file age.h with code to prevent multiple inclusion.
an class implementation file age.cpp.
a text file task_2_3.txt containing compilation messages and sample runs. Note
You have to include the code for class DateTime in age.h and age.cpp.
You may include the code for class WeekDay in age.h and age.cpp.
Do not modify DateTime and Age class public and protected sections. You may add private members (data/functions) only.
There is no need to implement error exception.
You may use sample_AGE_app.cpp to test your implementation. Expected output:
C:>a
Birthday: 12/25/94 03:04:05
Current date: 04/15/15 15:17:15
Age is 22 years old.
Birthday: 12/25/94 03:04:00
Birthday: 12/25/94 03:00:00
Birthday: 12/25/94 00:00:00
Birthday: 04/15/15 00:00:00
Age is 1 days old.
Birthday: 04/01/15 00:00:00
Age is 15 days old.
Birthday: 03/15/15 00:00:00
Age is 2 months old.
Birthday: 12/25/14 00:00:00
Age is 2 years old.
Birthday: 01/25/14 00:00:00
You should also use your own test cases to test for error inputs.
Marking Criteria
Marks
Age() and display()
12
age.h with code to prevent multiple inclusion.
2
age.cpp
4
Compilation messages and sample run outputs (if the program runs correctly)