Question: 14.20 Day of Year - class tutorial In this exercise, we will develop a class called DayOfYear. The class should contain: Private member variables for

14.20 Day of Year - class tutorial

In this exercise, we will develop a class called DayOfYear. The class should contain:

  1. Private member variables for day (int) and month (int).

  2. Mutator (set) and accessor (get) functions for those private member variables.

  3. A default constructor (no parameters) that initializes the date to January 1st. This is done by setting the day and month to 1 inside the constructor method.

  4. A constructor that takes in two parameters to initialize day and month. If invalid parameters are used for month and/or day (e.g. day > 31 or negative), use the default value.

  5. A function called toString() that returns the date as a string. For example "May 3" or "June 22".

  6. A function called printDate() that will print out the date to the screen

  7. A function called printDate(int year) but with an extra parameter for the year that will print the date (including year) to the screen.

  8. The exercise also needs ==, which returns true if both day and months are equal, and >, which returns true if the first day comes after the second (A>B is true if A comes after B). Please add this to the exercise and to the instructions. Also add test cases.

The main function is already implemented for you.

C++

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!