Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions