Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Supply the following Supply the following public member functions in your class. A default constructor ( taking no arguments ) that initializes the Date object

Supply the following
Supply the following public member functions in your class.
A default constructor
(
taking no arguments
)
that initializes the Date object to Jan
1
,
2
0
0
0
.
A constructor taking three arguments
(
month
,
day, year
)
that initializes the Date object to the parameter values.
It sets the Date's year to
1
9
0
0
if the year parameter is less than
1
9
0
0
It sets the Date's month to
1
if the month parameter is outside the range of
1
to
1
2
.
It sets the Date's day to
1
if the day parameter is outside the range of days for the specific month. Assume February always has
2
8
days for this test.
A getDay member function that returns the Date's day value.
A getMonth member function that returns the Date's month value.
A getYear member function that returns the Date's year value.
A getMonthName member function that returns the name of the month for the Date's month
(
e
.
g
.
if the Date represents
2
/
1
4
/
2
0
0
0
,
it returns "February"
)
.
You can return a const char
*
or a std::string object from this function.
A print member function that prints the date in the numeric form MM
/
DD
/
YYYY to cout
(
e
.
g
.
0
2
/
1
4
/
2
0
0
0
)
.
Month and day must be two digits with leading zeros as needed.
A printLong member function that prints the date with the month's name in the form dd month yyyy
(
e
.
g
.
1
4
February
2
0
0
0
)
to cout. This member function should call the getMonthName
(
)
member function to get the name. No leading zeroes required for the day.
The class data members should be set to correct values by the constructor methods so the get and print member functions simply return or print the data member values. The constructor methods must validate their parameter values
(
eg
.
verify the month parameter is within the range of
1
to
1
2
)
and only set the Date data members to represent a valid date, thus ensuring the Date object's data members
(
i
.
e
.
its state
)
always represent a valid date.
The print member function should output the date in the format MM
/
DD
/
YYYY with leading zeros as needed, using the C
+
+
IOStreams cout object. To get formatting to work with C
+
+
IOStreams
(
cout
)
,
look at the setw
(
)
and setfill
(
)
manipulator descriptions, or the width
(
)
and fill
(
)
functions in the chapter on the C
+
+
I
/
O System.
#include
#include
#include
using namespace std;
/
/
or use individual directives, e
.
g
.
using std::string;
class Date
{
/
/
methods and data necessary
}
;

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

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

Students also viewed these Databases questions

Question

Why is rejecting ????0 a reliable decision?

Answered: 1 week ago

Question

2. What role should job descriptions play in training at Apex?

Answered: 1 week ago