Question: Question 2: Create Simple Classes You are asked to create an application to manage employees. Two classes, Date and Employee, are designed. The details of

 Question 2: Create Simple Classes You are asked to create anapplication to manage employees. Two classes, Date and Employee, are designed. Thedetails of the Date class: The properties: day (type of int), month

Question 2: Create Simple Classes You are asked to create an application to manage employees. Two classes, Date and Employee, are designed. The details of the Date class: The properties: day (type of int), month (type of String), year (type of int). The months are "January", "February", ..., "December". The day is between 1 and 31. The year is between 1000 to 9999. Validation is needed for user input data. Constructor 1: a constructor without parameter. You need to give a valid default value for day, month, and year Constructor 2: a constructor takes three parameters: String monthString, int day, int year. You need to validate the actual parameters and initialize the properties. Use the dateOK() method given below to do the validation. Constructor 3: a constructor takes three parameters: int monthlnt, int day, int year. You need to validate the actual parameters and initialize the properties. You need to convert the int monthlnt to String, e.g. "January", and store the string to the property month. public boolean equals(Date otherDate): return true when otherDate has the same day, month and year. private String monthString(int): convert an integer month to its corresponding name (String) private boolean dateOK(String, int, int): validate if the actual parameters represent a valid date. See the definition of the properties for validate range. Leap year() is checked for February. No other special rules need to apply. private boolean dateOK(int, int, int): validate if the actual parameters represent a valid date. (different than the above one). See the definition of the properties for validate range. Leap year is checked for February. No other special rules need to apply public setDate(int, int, int): validate the actual parameters and set the values of the properties public setDate(String, int, int): validate the actual parameters and set the values of the properties public int getDay(), public int getMonth(), public void getYear(): the accessors of the properties. Notice that getMonth() converts the string of month to integer and returns the integer. public void setDay(int), public void setMonth(int), public void setMonth(String), public set Year(int): the mutators of the properties. (*) Leap years occur in years exactly divisible by four, except that years ending in 00 are leap years only if they are divisible by 400. The details of the Employee class: The properties: o The employee name: type of String o The hiring date: type of Date Constructor 1: a constructor without parameter. You need to give a valid default value for the employee name and the hiring date Constructor 2: a constructor takes two parameters: String aName, Date aDate.. public int seniority(Employee e): compare the seniority of this Employee and the Employee e. The seniority is decided by the hiring date. It returns O, if the two employees are hired on the same date. It returns -1, if this Employee is hired before the Employee e. It return 1, if this Employee is hired after the Employee e. public boolean equals(Employee e): return true when Employee e has the same day, month, year. public String getName(), public Date getHire Date(): the accessor of the properties. public void setHire Date (Date), public void setName(String): the mutator of the properties. A driver class to test the two classes: Create two Employee instances with different data: call them en and e2. Compare the seniority of eland e2: whoever hired earlier is more senior. Use the e3 is a second instance of e1 that the day, the month, and the year are the same as e 1. Use equals(Employee e) to compare el vs e2 , el vs e3. Use == to compare el vs e2, el vs e3. Print the status of e1,e2, and e3: print the values of the properties You can add any methods to implement the designed functions A sample output can be: The first employee (el): Jack October 5, 2019 The second employee (2): Peter December 3, 2008 Peter is more senior than Jack The duplicated employee (e3): Jack October 5, 2019 el.equals(3) => true e2.equals(3) => false (el == 3) => false (e2 == 3) => false

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!