Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions