Reference no: EM13306362
In this assignment you will be implementing three classes -Date (you would reuse the Date class after implementing toString() and equals() method), Employee and EmployeeTest with main method to test Employee class.
Class Employee has instance variables firstName, lastName, birthDate, hireDate and a variable to keep track of count of Employee objects. Members birthDate and hireDate are references to Date objects that have instance variables month, day and year.
Date Class
· Three instance variables month (1 - 12), day(1- 31) and year(any year) of appropriate type.
· Create the needed constructors
· Create methods setMonth( ), setDate( ), setYear ( ) with appropriate validation code
· setDate( ) method to confirm proper day value based on month and year. You can ignore the leap years.
· Create the getMethods for the instance variables
· Implement the toString() and Equals( ) method
Employee class
· Instance variables firstName, lastName, birthDate (Date type), Date hireDate (Date type)
· Variable to keep track of the count of Employee objects created. Note there will be only one copy of this variable that is shared by all the objects of this class
· Create appropriate constructors. Note that to initialize birthDate and hireDate the constructors will need parameters of Date type
· Create a method that returns the current count of the Employee objects
· Create a toString( ) and equals method ( )
EmployeeTest
· Implement the main method
· Create an Employee object with name Bob Jones with birthDate 10/14/1986 and hireDate as 5/1/2008
· Call the toString method on the Employee object and display it on the console window.
· Create another Employee object with name John Doe with birthDate 7/10/1973 and hireDate as 1/1/2012
· Call the toString method on the Employee object and display it on the console window.
· Display the current count of Employee objects by calling getCount( ) method
· Demonstrate the usage of equals method on the Employee objects.
Here is the Date class to reuse
public class Date {
private int day;
private int month;
private int year;
public Date(int day, int month, int year) {
this.day = day;
this.month = month;
this.year = year;
}
public Date() {
day = 0;
month = 0;
year = 0;
}
public void setDay(int day) {
this.day = day;
}
public void setMonth(int month) {
this.month = month;
}
public void setYear(int year) {
this.year = year;
}
public int getDay() {
return day;
}
public int getMonth() {
return month;
}
public int getYear() {
return year;
}
}