- Given a class named dateType that has the following properties:
- Data members (all of them are whole numbers)
- mm: month of the date
- dd: day of the date
- yy: year of the date
- Member functions
- setDate(months, days, years)
- //Function to set the date
- //The date is set according to the parameters
- //Postcondition: mm = months; dd = days; yy = years
- // The function checks whether the values of months, ,
- // days and years are valid. If a value is invalid,
- // the default value 0 is assigned.
- getDate (months, days, years)
- //Function to return the components of the date
- //Postcondition: months = mm; days = dd; years = yy
- printDate()
- //Function to print the date
- //Postcondition: date is printed in the form “mm/dd/yyyy”
- incrementDate()
- //Function to increment the date by one day.
- //Postcondition: The date is incremented by one day
- // If after incrementing the day, its value goes beyond the last
- // day of the month, the day is reset to 1 and the month incremented by one.
- // If the month goes beyond the last month of the year, it is reset to 1
- // and the year incremented by one.
- daysToDate(otherDate)
- //Function to return the number of days between two dates.
- //Postcondition: Returns the number of days between self and otherDate
- // as a whole number. The number returned is an absolute value.
- dateType(months=1, days=1, years=1900);
- //Constructor with default parameters
- //The date is set according to the parameters.
- //Postconditions: mm = months; dd = days; yy = years
- // The constructor checks whether the values of months,
- // days, and years are valid. If a value is invalid,
- // the default value (1 for days and months, 1900 for years) is assigned.
- declare and define it and then write a client program for testing it.
- The class must have the members described above and you have to determine the data types for the parameters and function values.
- To implement member function daysToDate(otherDate) use the math formula for calculating the serial Julian date found at http://codecogs.izyba.com/cog-268
- For your reference I will post the executable of my solution. Run it and see what your program is expected to do. It is your responsibility to understand the requirements specified on this handout; if you have doubts about certain aspects of the problem then you must ask the designer of the class (me) for more details. Of course, your questions should be as specific as possible. You may also consult with other programmers (classmates) through Blackboard.
- Read the documentation above carefully to understand how the members of the class must be implemented and used. If you find inconsistencies or have some questions please post them on the corresponding topic of the discussion board. I will first wait for somebody to reply and then will provide my answer.
- Your program is expected to work very similarly to mine. There may be minor differences in format such as alignment, titles, or content of prompts but in general they should have the same behavior. Please thoroughly analyze my solution to get a good idea of what you need to do. If your class is written according to my specifications I should be able to test it with my client program (which is what I am planning to do) without having any problems.
- For this assignment, you need to create a project and add the three files indicated (the client program, the header file, and the object file for the class). See the handout provided in Miscellaneous to learn how to work with projects in Visual C++.
- If you want to submit as a team (and I suggest you to do so) please post a message on the discussion board stating the name of the teammates.
- Submit your source program, and the UML corresponding to the dateType class (in a Word file) through the Blackboard “Assignments” tool. Do NOT email them.
wertwertwert
By: rwertwrt | Date: Sep 20 2007 02:34 | Format: None | Expires: never | Size: 3.78 KB | Hits: 1462
Latest pastes
1 days ago
1 days ago
2 days ago
4 days ago
5 days ago