Question: Hello I would like to check if the code follows all the requirements. Thanks. Date.h and testDate.cpp Design a class called Date. The Date class

Hello I would like to check if the code follows all the requirements. Thanks.

Date.h and testDate.cpp

Design a class called Date. The Date class should store a date in three integers: month, day, and year. There should be member functions to print the date in the different forms supported by the member methods. Here is the set of testing that you should include in the main application:

 // using the overloaded constructor. Date today(12, 25, 2012); // Show the date in form #1. today.showDate1(); // Store a new month, day, and year // in the object. today.setMonth(8); today.setDay(16); today.setYear(2012); // Show the date in form #2. today.showDate2(); // Show the date in form #3. today.showDate3(); // Test invalid date. Date someday(12, 32, 2012); 

Demonstrate the class by writing a complete program implementing it. Input Validation: Do not accept values for the day greater than 31 or less than 1. Do not accept values for the month greater than 12 or less than 1.

Date.h

#include #include #include #ifndef DATE_H #define DATE_H class Date { private: int month; int day; int year; std::vector<:string> months{ "Janurary", "Feburary", "March", "April" , "May", "June", "July", "August", "September", "October", "November", "December" }; bool check() { int maxDays = 0; maxDays = (tolower(months.at(month - 1).at(2)) == 'y') || (tolower(months.at(month - 1).at(3)) == 'u') || (tolower(months.at(month - 1).at(3)) == 'c') || (tolower(months.at(month - 1).at(3)) == 'y') || (tolower(months.at(month - 1).at(3)) == 'o') || ((tolower(months.at(month - 1).at(3)) == 'e') && (tolower(months.at(month - 1).at(0)) == 'd')); //check max days maxDays = 30 + maxDays - ((tolower(months.at(month - 1).at(0)) == 'f') * 2); if (month > 0 && month 0 && day

testDate.cpp

#include "Date.h" #include using namespace std; void Date::setMonth(int m) { month = m; } void Date::setDay(int d) { day = d; } void Date::setYear(int y) { year = y; } int const Date::getMonth() { return month; } int const Date::getDay() { return day; } int const Date::getYear() { return year; } void Date::showDate1() { if (check()) { cout

Hello I would like to check if the code follows all the

12/25/2012 August 16, 2012 16 August 2012 32 is not a valid value for the day. execution time : 0.105 S Process returned 1 (@x1) Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!