Question: Class Date This composition Lab contains classes Date, and Employee. Class Date declares private variables month, day and year to represent a date. The constructor
Class Date
This composition Lab contains classes Date, and Employee. Class Date declares private variables month, day and year to represent a date. The constructor receives three int parameters. The method checkMonth uses to validate the monthif the value is out-of-range. The method checkDay is to validate the day based on the current month and year. Determines whether the day is correct based on the number of days in the particular month. If the day is not correct.
Class Employee
Class Employee has private variables firstName, lastName, birthDate and hire-Date. The Members firstName and lastName are String. Members birthDate and hireDate are references to Date objects. This demonstrates that a class can have as instance variables references to objects of other classes (Composition). The Employee constructor takes four parametersfirst, last, dateOfBirth and dateOf-Hire.
The objects referenced by the parameters are assigned to the Employee objects private variables.
Main function
Creates two Employee objects and initializes the data members by passing to the constructor and (first and last names) and (the birthday and hire date).
Display the values of its private variables and demonstrate that the object was initialized properly.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
