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:
-
Private member variables for day (int) and month (int).
-
Mutator (set) and accessor (get) functions for those private member variables.
-
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.
-
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.
-
A function called toString() that returns the date as a string. For example "May 3" or "June 22".
-
A function called printDate() that will print out the date to the screen
-
A function called printDate(int year) but with an extra parameter for the year that will print the date (including year) to the screen.
-
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
Get step-by-step solutions from verified subject matter experts
