Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

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

Current Trends In Database Technology Edbt 2006 Edbt 2006 Workshops Phd Datax Iidb Iiha Icsnw Qlqp Pim Parma And Reactivity On The Web Munich Germany March 2006 Revised Selected Papers Lncs 4254

Authors: Torsten Grust ,Hagen Hopfner ,Arantza Illarramendi ,Stefan Jablonski ,Marco Mesiti ,Sascha Muller ,Paula-Lavinia Patranjan ,Kai-Uwe Sattler ,Myra Spiliopoulou ,Jef Wijsen

2006th Edition

3540467882, 978-3540467885

More Books

Students also viewed these Databases questions

Question

find all matrices A (a) A = 13 (b) A + A = 213

Answered: 1 week ago