Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a Date class that contains: three private data members: month day o year (I leave it to you to decide the type) setters and

image text in transcribed
image text in transcribed
Create a "Date" class that contains: three private data members: month day o year (I leave it to you to decide the type) "setters" and "getters" for each of the data (6 functions in total) One advantage of a "setter" is that it can provide error checking. Add assert statements to the setter to enforce reasonable conditions. For example, day might be restricted to between 1 and 31 inclusive. one default constructor (no arguments) .one constructor with three arguments: month, day, and year Add assert statements to enforce reasonable conditions. . a printDate function. This function will have no arguments and return void a sameMonth function. This function will have one Date argument and a boolean return type In main (in the following order): 1. instantiate one date object (datel) using the default constructor 2. use the getters to display the month, day, and year of datel (should print the default values) 3. read keyboard input from the user for a month, day and year 4. use the setters to set the values of datel to the values that came from the user 5. read keyboard input from the user for a second date 6. use the constructor with three arguments to instantiate date to the second date input from the user 7. print both objects using printDate 8. print a message to say if the two months are the same (testing the sameMonth function) Your code should be in three files: Date.h contains the class definition Date.cpp o includes "Date.n contains the functions for the class . main.cpp o includes "Date.h" tests the class Sample Output (Two Runs) >./main Testing the default constructor and the getters The initialized date is (M-D-Y):1-1-1 Please enter a date: (Month Day Year): 11 03 1976 Please enter a second date: (Month Day Year): 03 03 1999 Printing the two days: The date is (M-D-Y): 11-3-1976 The date is (M-D-Y): 3-3-1999 The months are different > ./main Testing the default constructor and the getters The initialized date is (M-D-Y): 1-1-1 Please enter a date: (Month Day Year): 12 15 2009 Please enter a second date: (Month Day Year): 12 25 2020 Printing the two days: The date is (M-D-Y): 12-15-2009 The date is (M-D-Y): 12-25-2020 The months are the same

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

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

Why is Germany so successful at international trade?

Answered: 1 week ago

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago