Program Assignment

apap7.2 - Classes/Function overloading

Create a date class composed of day, month, and year.

Create two constructors. The default constructor (no parameters) sets the date to 1/1/0000 using a constructor initialization list, and second constructor that uses three parameters: (month, day, year) to set the date. Make sure you check for valid before setting the date. Vaild years range from 0 to 16383. The second constructor cannot use an initialization list.

Overload the << operator so the output will appear in the format:

 	mm/dd/yyyy

Write three mutator (overloading) functions with the same name ChangeDate.

  1. The first function should change the date via three parameters passed: month, day, and year in that order. Check for validity.
  2. The second function receives an apstring which is in the form:
    "2/4/1992"
    The number before the first "/" is the month, the number after the first "/" is the day, and the number after the second "/" is the year. Check for validity.
  3. The third function receives one 32 bit integer value. 20 bits are needed to store a date from the date 1/1/0000 to 12/31/16383. 14 bits for the year, 5 bits for the day, and 4 bits for the month. Since we have 32 bits in our integer data type, we can easily store the date using the following technique:
    integer value = year + 16384(day) + 524288(month)
    Check for validity.

The file apap7-2.cpp contains code for returning the correct number of days in a month, and converting a string into an integer value which you can place into your program.

Use the program testdate.cpp when turning in your program.