Question: public class Employee { public int getHours() { return 40; // works 40 hours / week } public double getSalary() { return 40000.0; // $40,000.00

public class Employee { public int getHours() { return 40; // works 40 hours / week } public double getSalary() { return 40000.0; // $40,000.00 / year } public int getVacationDays() { return 10; // 2 weeks' paid vacation } public String getVacationForm() { return "yellow"; // use the yellow form } } public class Lawyer extends Employee { public int getVacationDays() { return super.getVacationDays() + 5; } public String getVacationForm() { return "pink"; } public void sue() { System.out.println("I'll see you in court!"); } }

Given the Employee class and the Lawyer class above a. Write an employee class Janitor to accompany the other employees. Janitors work twice as many hours (80 hours/week), they make $30,000 ($10,000 less than others), they get half as much vacation (only 5 days), and they have an additional method named clean that prints "Cleaning!." Use the super keyword to interact with the Employee superclass as appropriate. b. Write an employee class HarvardLawyer to accompany the other employees. Harvard lawyers are like normal lawyers, but they make 20% more money than a normal lawyer, they get 3 days more vacation, and they have to fill out four of the lawyer's forms to go on vacation. That is, the getVacationForm method should return "pink". (If the normal Lawyer's vacation form ever changed, the HarvardLawyer's should as well. For example, if Lawyer's vacation form changed to "red", the HarvardLawyer's should return "red".) Use the super keyword to interact with the Employee superclass as appropriate. c. Write a client class called EmployeeMain that creates objects of Lawyer, Janitor and HardvardLawyer class in the main method. Write a method called printEmployee() that takes an object of Employee as a parameter and prints out salary, hour, vacation days and vacation form for the employee. Also call clean() method if you are printing a Janitor object. Call printEmployee() method from main method. Example output for Lawyer object Lawyer: Salary: $40000 Hours: 40 Vacation days: 15 Vacation form: pink

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!