Public paste
By: rwertwrt | Date: Sep 20 2007 02:34 | Format: None | Expires: never | Size: 3.78 KB | Hits: 1379

  1.         Given a class named dateType that has the following properties:
  3. Data members (all of them are whole numbers)
  5. mm: month of the date
  6. dd: day of the date
  7. yy: year of the date
  9. Member functions
  11. setDate(months, days, years)
  12. //Function to set the date
  13. //The date is set according to the parameters
  14. //Postcondition: mm = months; dd = days; yy = years
  15. //  The function checks whether the values of months, ,
  16. //  days and years are valid. If a value is invalid,
  17. //  the default value 0 is assigned.
  19. getDate (months, days, years)
  20. //Function to return the components of the date
  21. //Postcondition: months = mm; days = dd; years = yy
  23. printDate()
  24. //Function to print the date
  25. //Postcondition: date is printed in the form “mm/dd/yyyy”
  27. incrementDate()
  28. //Function to increment the date by one day.
  29. //Postcondition: The date is incremented by one day
  30. // If after incrementing the day, its value goes beyond the last
  31. // day of the month, the day is reset to 1 and the month incremented by one.
  32. // If the month goes beyond the last month of the year, it is reset to 1
  33. // and the year incremented by one.
  35. daysToDate(otherDate)
  36. //Function to return the number of days between two dates.
  37. //Postcondition: Returns the number of days between self and otherDate
  38. // as a whole number. The number returned is an absolute value.
  40. dateType(months=1, days=1, years=1900);
  41. //Constructor with default parameters
  42. //The date is set according to the parameters.
  43. //Postconditions: mm = months; dd = days; yy = years
  44. //  The constructor checks whether the values of months,
  45. //  days, and years are valid. If a value is invalid,
  46. //  the default value (1 for days and months, 1900 for years) is assigned.
  50. declare and define it and then write a client program for testing it.
  52. The class must have the members described above and you have to determine the data types for the parameters and function values.
  54.         To implement member function daysToDate(otherDate) use the math formula for calculating the serial Julian date found at
  56. 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.
  58.         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.
  60.         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.
  62.         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++.
  63.         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.
  64.         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.