Private Member Functions The functions declared private above, is Leap, daysPerMonth, name, number, are helper functions - member functions that will never be needed by a user of the class, and so do not belong to the public interface (which is why they are "private"). They are, however, needed by the interface functions (public member functions), which use them to test the validity of arguments and construct valid dates. For example, the constructor that passes in the month as a string will call the number function to assign a value to the unsigned member variable month. isLeap: The rule for whether a year is a leap year is: • (year % 4 == 0) implies leap year • except (year % 100 == 0) implies NOT leap year • except (year % 400 == 0) implies leap year So, for instance, year 2000 is a leap year, but 1900 is NOT a leap year. Years 2004, 2008, 2012, 2016, etc. are all leap years. Years 2005, 2006, 2007, 2009, 2010, etc. are NOT leap years. Output Specifications Read the specifications for the print function carefully. The only cout statements within your Date member functions should be: 1. the "Invalid Date" warnings in the constructors 2. in your two print functions Required Main Function You must use this main function and global function getDate as they are here. You may not change these functions at all. Copy-and-paste these into your main.cpp file and then add the Date class. Date getDate(); int main() { } Date test Date; test Date = getDate(); cout << endl; cout << "Numeric: "; testDate.printNumeric (); cout << endl; cout << "Alpha: "; testDate.printAlpha (); cout << endl; return 0; Date getDate() { int choice; unsigned monthNumber, day, year; string monthName; cout << "Which Date constructor? (Enter 1, 2, or 3)" << endl << "1 Month Number" << endl << "2 Month Name" << endl << "3 default" << endl; cin >> choice; cout << endl;
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
There's additional code that's required. I have attached the instructions below. It's continuous.
![Private Member Functions
The functions declared private above, is Leap, daysPerMonth, name, number, are helper functions - member functions
that will never be needed by a user of the class, and so do not belong to the public interface (which is why they are "private").
They are, however, needed by the interface functions (public member functions), which use them to test the validity of
arguments and construct valid dates. For example, the constructor that passes in the month as a string will call the number
function to assign a value to the unsigned member variable month.
is Leap: The rule for whether a year is a leap year is:
.
(year % 4 == 0) implies leap year
●
except (year % 100 == 0) implies NOT leap year
• except (year % 400 == 0) implies leap year
So, for instance, year 2000 is a leap year, but 1900 is NOT a leap year. Years 2004, 2008, 2012, 2016, etc. are all leap years.
Years 2005, 2006, 2007, 2009, 2010, etc. are NOT leap years.
Output Specifications
Read the specifications for the print function carefully. The only cout statements within your Date member functions
should be:
1. the "Invalid Date" warnings in the constructors
2. in your two print functions
Required Main Function
You must use this main function and global function getDate as they are here. You may not change these functions at all.
Copy-and-paste these into your main.cpp file and then add the Date class.
Date getDate();
int main() {
}
Date test Date;
test Date = getDate();
cout << endl;
cout << "Numeric: ";
testDate.print Numeric ();
cout << endl;
cout << "Alpha: ";
testDate.printAlpha ();
cout << endl;
return 0;
Date getDate() {
int choice;
unsigned monthNumber, day, year;
string monthName;
cout << "Which Date constructor? (Enter 1, 2, or 3)" << endl
<< "1
Month Number" << endl
<< "2
Month Name" << endl
<< "3 default" << endl;
cin >> choice;
cout << endl;](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F86f873bd-bb8a-47e9-968f-33877241ae61%2Fb3bc9b06-817f-41a6-b7c7-88d2b42f6c00%2Faj9id0l_processed.png&w=3840&q=75)
![/* Outputs to the console (cout) a Date exactly in the format "3/1/2012".
Does not output a newline at the end.
};
*/
void printNumeric () const;
/* Outputs to the console (cout) a Date exactly in the format "March 1, 2012".
The first letter of the month name is upper case, and the month name is
printed in full - January, not Jan, jan, or january.
Does not output a newline at the end.
*/
void printAlpha () const;
private:
/* Returns true if the year passed in is a leap year, otherwise returns false.
*/
bool isLeap (unsigned y) const;
/* Returns number of days allowed in a given month
e.g. daysPerMonth (9, 2000) returns 30.
Calculates February's days for leap and non-leap years,
thus, the reason year is also a parameter.
=/
-
unsigned daysPerMonth (unsigned m, unsigned y) const;
/* Returns the name of a given month
- e.g. name (12) returns the string "December"
*/
string name (unsigned m) const;
/* Returns the number of a given named month
- e.g. number ("March") returns 3.
*/
unsigned number (const string &mn) const;
Note: Placing the error messages into the constructors like the above is not necessarily a good way to handle constructor errors, but until you
learn about exceptions, it's the best we can do.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F86f873bd-bb8a-47e9-968f-33877241ae61%2Fb3bc9b06-817f-41a6-b7c7-88d2b42f6c00%2Fbxb3ek_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 5 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Can you please explain this part again?
Date::Date :day(1),month(1),year(2000)
{
}
Is it written this way? I am a little confused about how to write this portion at the start in the Date.cpp file, can you please rewrite this part more clearly?
![Step 3
program:
Date.cpp
#include <iostream>
#include <string>
#include "Date.h"
using namespace std;
Date::Date()
:day(1),month(1),year(2000)
{
}](https://content.bartleby.com/qna-images/question/86f873bd-bb8a-47e9-968f-33877241ae61/03aa2559-25ba-4e1a-9f33-c3e4abc785de/ffblzct_thumbnail.png)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)