Page 1 of 1

Problem Defınition Build a Date class and a main function to test it. Specifications Below is the interface for the Date

Posted: Tue Jul 12, 2022 8:17 am
by answerhappygod
Problem Definition Build A Date Class And A Main Function To Test It Specifications Below Is The Interface For The Date 1
Problem Definition Build A Date Class And A Main Function To Test It Specifications Below Is The Interface For The Date 1 (52.81 KiB) Viewed 30 times
Problem Definition Build A Date Class And A Main Function To Test It Specifications Below Is The Interface For The Date 2
Problem Definition Build A Date Class And A Main Function To Test It Specifications Below Is The Interface For The Date 2 (43.82 KiB) Viewed 30 times
Problem Definition Build A Date Class And A Main Function To Test It Specifications Below Is The Interface For The Date 3
Problem Definition Build A Date Class And A Main Function To Test It Specifications Below Is The Interface For The Date 3 (74.18 KiB) Viewed 30 times
Problem Definition Build A Date Class And A Main Function To Test It Specifications Below Is The Interface For The Date 4
Problem Definition Build A Date Class And A Main Function To Test It Specifications Below Is The Interface For The Date 4 (38.02 KiB) Viewed 30 times
c++ code
please follow the instructions on the images I haveprovided above
Problem Defınition Build a Date class and a main function to test it. Specifications Below is the interface for the Date class: it is our "contract" with you: you have to implement everything it describes, and show us that it works with a test harness that puts it through its paces. The comments in the interface below should be sufficient for you to understand the project (use these comments in your Date declaration), without the need of any further documentation. But of course, as always, you can ask us questions on the discussion boards.

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 dmn) 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. 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( m Date testDate; testDate = getDate (); cout << endl; cout << "Numeric: "; testDate printMumeric () cout << endl; cout << "zlpha: ; testDate printalpha (); cout << endl; Date getDate (); int main( \{ Date testDate; testDate = 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; cout << "Which <<1 - Mont <<" Mon <<3 - def cin >> choice; cout << endli if ( choice ==1){ cout ≪ "month number? "; cin ≫ monthNumber; cout << endl; cout ≪ "day? "; cin ≫ day; cout ≪< endl; cout < "year? "; cin → year; cout << endl; return Date (monthNumber, day, year); \} else if (choice ==2 ) \{ cout e< "month name? "; cin ≫ monthName; cout ≪ endl; cout < "day?"; cin ≫ day; cout << endl; cout < "year? "; cin ≫ year; cout << endl; return Date (monthName, day, year); \} else } return Date(); \}