Explore BrainMass
Share

Explore BrainMass

    C++ Date class Inheritance and Polymorphism Program

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    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

    © BrainMass Inc. brainmass.com April 1, 2020, 7:40 pm ad1c9bdddf
    https://brainmass.com/computer-science/java/c-date-class-inheritance-polymorphism-program-423105

    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