We're Open
+44 7340 9595 39
+44 20 3239 6980

[Solved] DO NOT MODIFY DATETIME AND AGE CLASS PUBLIC AND PROTECTED SECTIONS

  100% Pass and No Plagiarism Guaranteed

[Solved] DO NOT MODIFY DATETIME AND AGE CLASS PUBLIC AND PROTECTED SECTIONS

In this paper, you are required to provide a header file age.h with code to prevent multiple inclusion and an class implementation file age.cpp. You are asked not to modify DateTime and Age class public and protected sections. You may add private members (data/functions) only. Furthermore, You have to 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

    Age(int y, int m, int d, int h = 0, int min = 0, int s = 0);

    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.

    void display();

      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

Current date: 04/15/15 15:17:15

Age is 22 years old.

 

Birthday: 12/25/94 03:00:00

Current date: 04/15/15 15:17:15

Age is 22 years old.

 

Birthday: 12/25/94 00:00:00

Current date: 04/15/15 15:17:15

Age is 22 years old.

 

Birthday: 04/15/15 00:00:00

Current date: 04/15/15 15:17:15

Age is 1 days old.

 

Birthday: 04/01/15 00:00:00

Current date: 04/15/15 15:17:15

Age is 15 days old.

 

Birthday: 03/15/15 00:00:00

Current date: 04/15/15 15:17:15

Age is 2 months old.

 

Birthday: 12/25/14 00:00:00

Current date: 04/15/15 15:17:15

Age is 2 years old.

 

Birthday: 01/25/14 00:00:00

Current date: 04/15/15 15:17:15

Age is 2 years old.

 

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)

2

 

 

 


100% Plagiarism Free & Custom Written,
Tailored to your instructions


International House, 12 Constance Street, London, United Kingdom,
E16 2DQ

UK Registered Company # 11483120


100% Pass Guarantee

STILL NOT CONVINCED?

View our samples written by our professional writers to let you comprehend how your work is going to look like. We have categorised this into 3 categories with a few different subject domains

View Our Samples

We offer a £ 2999

If your assignment is plagiarised, we will give you £ 2999 in compensation

Recent Updates

Details

  • Title: [Solved] DO NOT MODIFY DATETIME AND AGE CLASS PUBLIC AND PROTECTED SECTIONS
  • Price: £ 99
  • Post Date: 2021-10-25T04:42:52+00:00
  • Category: Assignment Queries
  • No Plagiarism Guarantee
  • 100% Custom Written

Customer Reviews

[Solved] DO NOT MODIFY DATETIME AND AGE CLASS PUBLIC AND PROTECTED SECTIONS [Solved] DO NOT MODIFY DATETIME AND AGE CLASS PUBLIC AND PROTECTED SECTIONS
Reviews: 5

A masterpiece of assignment by , written on 2020-03-12

Writing is not my field. I take help from this website for my accounting assignment. The work is good and I scored good grades in it. Thank you from the bottom of my heart.
Reviews: 5

A masterpiece of assignment by , written on 2020-03-12

My order went 3 hours late and I also went mad. Then the customer support team calmed me down and offered me a flat discount of 50%. However, I did get my order and chilled out as the work was exactly what I requested. Next time I would place my order a bit sooner to save any trouble.