Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

public class Employee { 
 public int getHours() { // works 40 hours / week 

return 40; }

 public double getSalary() { // $40,000.00 / year 
 return 40000.0; } 
 public int getVacationDays() { // 2 weeks' paid vacation 

return 10; }

 public String getVacationForm() { // use the yellow form 
 return "yellow"; } 

}

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

  1. Write an employee class Programmer to accompany the other employees. Programmers work normal hours (40 hours/week), they make $70,000 ($25,000 more than others), they get 10 days of vacation and have an ability to write code. (You need to implement an appropriate method; the implementation should only contain a print statement that yields Writing code...).

  2. Write an employee class SeniorProgrammer to accompany the other employees. Software engineers make 25% more money than programmers, they get 4 days more vacation, and they are also capable of leading meetings (You need to implement an appropriate method; the implementation should only contain a print statement that yields Leading a meeting...).

  3. Write a client class called EmployeeMain that creates objects of Programmer and SeniorProgrammer and Lawyer classes 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 code() method if a Programmer object is being printed out, and call

    leadMeeting() if a SeniorProgrammer object is being printed out. Call printEmployee() method from main method for both objects.

    Note: please remember that the best way to efficiently print out information about an object is to implement the toString() method.

    Example output for Lawyer object

    Lawyer: Salary: $40000 Hours: 40 Vacation days: 15 Vacation form: pink

  4. Submit an answer to the following question. Why is it possible to have one

printEmployee() method for different types of employees?

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

Students also viewed these Databases questions