Write a program that defines a class date and implement it


Task:

Write a program that defines a class Date and implement it as required. The class Date should consist of three private member variables: year of type int, month of type int, and day of type int. The class Date should also include the following public member functions:

1.to output the year, month, and day in the format of yyyy-mm-dd.

2.to set the year, month and day according to the parameters. Data validation should be provided. A valid year is an integer between 1900 and 2015 inclusively. A valid month is an integer between 1 and 12 inclusively. A valid day should be an integer between

1 and n, where n = 31 if month is 1, 3, 5, 7, 8, 10, or 12; n = 30 if month is 4, 6, 9, or 11; n = 28 if month = 2.

Use 1900 for the year, 1 for the month, and 1 for the day, respectively, if a data is invalid.

3.to return the year.

4.to return the month.

5.to return the day.

6.A constructor to initialize year, month, and day with default parameters: The default values of year, month, and day are 1900, 1, and 1 respectively.

7. to compare two objects' values. Return true if they are the same, otherwise, return false. has a formal parameter which is a object.

You should put the class definition in a header file Date.h and put the class implementation in an implementation file Date.cpp. Write a test program to test your class implementations.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a program that defines a class date and implement it
Reference No:- TGS02944970

Expected delivery within 24 Hours