Define , implement and test a class Date using C++ with following specifications

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Define , implement and test a class Date using C++ with following specifications

The Date class consists of three private member variables:
No. Member Variable
1 year
Description
An int variable that holds the value of a year.
An int variable that holds the value of a month.
An int variable that holds the value of a day.
2
month
3
day
The Date class has the following public member functions:
Description
No. Member Function
Constructor with Initializes year, month, and day with three int arguments. The default
default
1
values for the year, month, and day are 2001, 1, and 1, respectively.
Data validation must be provided as in setDate.
Initializes year, month, and day of a new Date object with an
existing Date object.
Returns the value in year.
Returns the value in month.
Returns the value in day.
Sets the year, month and day with three int arguments. Data validation
should be provided as follows.
1) A valid year should be between 1900 and 2020, otherwise use 2001
for the year.
| 2) A valid month should be between 1 and 12, otherwise use 1 for the
parameters
2 Copy Constructor
getYear
getMonth
getDay
month.
3) A valid day should be between
• 1 and 31 if the month is 1, 3, 5, 7, 8, 10, or 12, (which means there
are 31 days in January, March, May, July, August, October, and
December.)
• 1 and 30 if the month is 4, 6, 9, or 11.
• 1 and 28 if the month is 2, i.e., simply assume there are 28 days in
February.
Use 1 for any invalid value.
Outputs the year, month, and day in the format of MM-DD-YYYY.
Compares two Date objects' values and returns true if they are the
same, otherwise returns false.
setDate
7
print
8
equals
m
Transcribed Image Text:The Date class consists of three private member variables: No. Member Variable 1 year Description An int variable that holds the value of a year. An int variable that holds the value of a month. An int variable that holds the value of a day. 2 month 3 day The Date class has the following public member functions: Description No. Member Function Constructor with Initializes year, month, and day with three int arguments. The default default 1 values for the year, month, and day are 2001, 1, and 1, respectively. Data validation must be provided as in setDate. Initializes year, month, and day of a new Date object with an existing Date object. Returns the value in year. Returns the value in month. Returns the value in day. Sets the year, month and day with three int arguments. Data validation should be provided as follows. 1) A valid year should be between 1900 and 2020, otherwise use 2001 for the year. | 2) A valid month should be between 1 and 12, otherwise use 1 for the parameters 2 Copy Constructor getYear getMonth getDay month. 3) A valid day should be between • 1 and 31 if the month is 1, 3, 5, 7, 8, 10, or 12, (which means there are 31 days in January, March, May, July, August, October, and December.) • 1 and 30 if the month is 4, 6, 9, or 11. • 1 and 28 if the month is 2, i.e., simply assume there are 28 days in February. Use 1 for any invalid value. Outputs the year, month, and day in the format of MM-DD-YYYY. Compares two Date objects' values and returns true if they are the same, otherwise returns false. setDate 7 print 8 equals m
Expert Solution
steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education