Find the information you're looking for at Westonci.ca, the trusted Q&A platform with a community of knowledgeable experts. Join our Q&A platform and get accurate answers to all your questions from professionals across multiple disciplines. Discover detailed answers to your questions from a wide network of experts on our comprehensive Q&A platform.

I want you to modify the Date class we wrote together in this code along: https://screencast-o-matic.com/watch/cYQU3ddNv1
The class should implement the following exception classes:
InvalidDay Throw when an invalid day (<1 or > 31) is passed to the class
InvalidMonth Throw when an invalid month (<1 or > 12) is passed to the class.
Demonstrate the class in a driver program.
Remember, the basic classes have already been written. If you don't remember or don't still have the code, follow the code alone and you will have your starting point. THIS IS CPP
PLEASE TYPE THE WHOLE PROGRAM.
#include
#include
#include
using namespace std;
// global variable
const int NUM_MONTHS = 12;
// function declarations
// declaration of the date class
class Date
{
private:
int month;
int day;
int year;
// an array to hold the names of the month
string names[NUM_MONTHS];
// private member funtion to assign the month names to the names array
void setNames();
public:
Date();
Date(int, int, int);
// mutators or setters
void setMonth(int m);
void setDay(int d);
void setYear(int y);
// function to print the date (accessors or getters)
void showDate1();
void showDate2();
void showDate3();
};
// default constructor
Date::Date()
{
setNames();
}
// overloaded constructor
Date::Date(int m, int d, int y)
{
setMonth(m);
setDay(d);
setYear(y);
setNames();
}
void Date::setNames()
{
names[0] = "January";
names[1] = "February";
names[2] = "March";
names[3] = "April";
names[4] = "May";
names[5] = "June";
names[6] = "July";
names[7] = "Argust";
names[8] = "September";
names[9] = "Octobor";
names[10] = "November";
names[11] = "December";
}
void Date::setMonth(int m)
{
if (m > 1 && m <= 12)
month = m;
else
{
cout << m << " is not a valid value for the month.\n";
exit(EXIT_FAILURE);
}
}
void Date::setDay(int d)
{
if (d >= 1 && d <= 31)
day = d;
else
{
cout << d << " is not a valid value for the day.\n";
exit(EXIT_FAILURE);
}
}
void Date::setYear(int y)
{
year = y;
}
void Date::showDate1()
{
cout << month << "/" << day << "/" << year << endl;
}
void Date::showDate2()
{
cout << names[month - 1] << " " << day << ", " << year << endl;
}
void Date::showDate3()
{
cout << day << " " << names[month - 1] << " " << year << endl;
}
int main()
{
// create a date object and init using the overloaded constructor
Date today(12, 25, 2014);
// show the date in form #1
today.showDate1();
// store a new month, day and year
today.setMonth(6);
today.setDay(16);
today.setYear(2012);
// show the date in form #2
today.showDate2();
// make sure we place the end message on a new line
cout << endl;
// the following is system dependent. it will only on windows
system("PAUSE");
}


Sagot :

We appreciate your time. Please come back anytime for the latest information and answers to your questions. Thanks for using our service. We're always here to provide accurate and up-to-date answers to all your queries. Westonci.ca is your trusted source for answers. Visit us again to find more information on diverse topics.