Share
Explore BrainMass

C++ Date class Inheritance and Polymorphism Program

The class Date was designed to implement the date in a program, but the method setDate and the constructor with parameters do not check whether the date is valid before storing the date in the data members. Rewrite the definitions of the method setDate and the constructor with parameters so that the value of month, day, and year are checked before storing the date into the data members. Add a method isLeapYear to check whether a year is a leap year. Then write a test program to test your class

Solution Preview

Dear Student, please find attached the C++ source code of Date.cpp which contains the Date class and testing code in the main() function. The test results look below:

*** Welcome to Date Test Program ***
Initialized date value:
1/31/2000
Set date ...

Solution Summary

The solution contains C++ source code with class Date and the main function that contains testing code. The output looks like
*** Welcome to Date Test Program ***
Initialized date value:
1/31/2000
Set date to April 1, 2005:
4/1/2005
...and more...

The solution also contains a Java version of the program.

$2.19