Question: In Java Given the Employee class and the Lawyer class above a. Write an employee class Programmer to accompany the other employees. Programmers make $80,000,
In Java
Given the Employee class and the Lawyer class above
a. Write an employee class Programmer to accompany the other employees. Programmers make $80,000, they get 5 days vacation, and they have an additional method named code that prints "Coding!." Use the super keyword to interact with the Employee superclass as appropriate. The getVacationForm method should return "grey".
b. Write an employee class SeniorProgrammer to accompany the other employees. Senior programmers are like normal programmers, but they make 30% more money than a normal programmer, they get 5 days more vacation, and they have to fill out four of the programmer's forms to go on vacation. That is, the getVacationForm method should return "greygreygreygrey". (If the normal Programmer's vacation form ever changed, the SeniorProgrammer's should as well. For example, if Programmer's vacation form changed to "red", the SeniorProgrammer's should return "redredredred".)
Use the super keyword to interact with the Employee superclass as appropriate.
c. Write a client class called EmployeeMain that creates objects of Programmer and SeniorProgrammer
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 code() method if you are printing a Programmer object. Call printEmployee() method from main method.
Example output for Programmer object
Programmer:
Salary: $80000
Hours: 40
Vacation days: 5
Vacation form: grey
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!");
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
