Compare and contrast the implementation of class Date Type used in the Case Study and the solution

Question:

Compare and contrast the implementation of class Date Type used in the Case Study and the solution proposed in Exercises 29 and 30. These two approaches represent the classic trade-off between space and algorithm complexity. Please comment.

Exercise 29.

Date Type keeps only the integer representation of the month, day, and year. When a month is wanted in string form, the string is
calculated. An alternate approach would be to add a string field to the date and calculate and store the string representation in the Initialize function. Which methods would have to be changed? Would this change make the use of an if statement to find the appropriate string more or less attractive? Write the code for this if statement.

Exercise 30.

What changes would be necessary if the number of days in the  month were carried as a data field in class Date Type rather than
being looked up when necessary? Would this change make the use of a switch statement to find the number of days in the month more attractive? Write the code for this switch statement.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

C++ Plus Data Structures

ISBN: 9781284089189

6th Edition

Authors: Nell Dale, Chip Weems, Tim Richards

Question Posted: