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 - year (I leave it to you to decide the

image text in transcribed
image text in transcribed
Create a "Date" class that contains: - three private data members: - month - day - 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 sameDay function. This function will have one Date argument and a boolean return type In main (in the following order): 1. instantiate one date object (date1) using the default constructor 2. use the getters to display the month, day, and year of date1 (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 date1 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 2 to the second date input from the user 7. print both objects using printDate 8. print a message to say if the two days are the same (testing the sameDay function) Your code should be in three files: - Date.h - contains the class definition - Date.cpp - includes "Date.h" - contains the functions for the class - main.epp - includes "Date.h" - tests the class If you are having trouble compiling your class, check for these common errors: 1. You have forgotten the semi-colon(; ) after the closing curly bracket ( } ) for the class definition (in the Date. h file) 2. You have forgotten the scope resolution as in: void Date: :setYear(int y ) (in the Date.cpp file) 3. You forgot the ( ) after the function name. For example, you should write: cout

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

More Books

Students also viewed these Databases questions

Question

2. Are you varying your pitch (to avoid being monotonous)?

Answered: 1 week ago

Question

3. Are you varying your speaking rate and volume?

Answered: 1 week ago