Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ven the Employee class and the Lawyer class above Write an employee class Softwa

ID: 3751536 • Letter: V

Question

ven the Employee class and the Lawyer class above Write an employee class SoftwareEngineer to accompany the other em- ployees. SoftwareEngineers work 10 more hours (50 hours/week), they make $55,000 (S15,000 more than others), they get half as much vacation (only 5 days), and they have an additional method named writeCode that prints "Coding! Use the super keyword to interact with the Employee su perclass as appropriate a) public class Employee public int getHours) public double getsalaryO public int getVacationDaysO public string getvacationFormO b) Write an employee class HarvardLanyer to accompany the other em- return 40 // works 40 hours/week ployees. 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 three of the lawyer's forms to go on vacation. That is the getvacationForm method should return "pinkpinkpink" (If the nor- mal Laxyer's vacation form ever changed, the HarvardLawyer's should as well. For example, if Lawyez's vacation form changed to "zed", the Haz- vardLawyez's should return "zedredred") Use the auper keyword to in teract with the Lawyer superclass as appropriate. return 40000.0 $40,000.00/ year return 10 // 2 weeks' paid vacation c) Write a client class called EmployeeClient that creates objects of La return "ye1low"use the yellow form yex, SofcwareEngineer and HardvardLawyer class in the main method. Write a method called printEmployee 0 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 print ing a SoftwareEngineer object. Call printEmployeeO method from main method Example output for Lawyer object Lawyer Salary: $40000 Hours: 40 Vacation days: 15 Vacation form: pink public class Lawyer extends Employee t public int getVacationDays public string getvacationFormO public void sue ) return super.getVacationDays 0+5 return "pink" System.out.println("I'11 see you in court)

Explanation / Answer

Employee.java

public class Employee {

public int getHours()

{

return 40;

}

public double getSalary()

{

return 40000.0;

}

public int getVacationDays()

{

return 10;

}

public String getVacationForm()

{

return "yellow";

}

}

_______________

Lawyer.java

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!");

}

}

________________

SoftwareEngineer.java

public class SoftwareEngineer extends Employee {

public int getHours()

{

return super.getHours()+10;

}

public double getSalary()

{

return super.getSalary()+15000;

}

public int getVacationDays()

{

return super.getVacationDays()/2;

}

public String getVacationForm()

{

return "yellow";

}

public void writecode()

{

System.out.println("Coding!");

}

}

_________________

HarvardLawyer.java

public class HarvardLawyer extends Lawyer {

public double getSalary()

{

return super.getSalary()+(super.getSalary()*0.20);

}

public String getVacationForm()

{

String str="";

for(int i=0;i<3;i++)

str+=super.getVacationForm();

return str;

}

public void sue()

{

System.out.println("I'll see you in court!");

}

public int getVacationDays()

{

return super.getVacationDays()+3;

}

  

}

______________________

EmployeeClient.java

public class EmployeeClient {

public static void main(String[] args) {

  

Lawyer l=new Lawyer();

SoftwareEngineer se=new SoftwareEngineer();

HarvardLawyer hl=new HarvardLawyer();

System.out.println(" Lawyer:");

printEmployee(l);

System.out.println(" Software Engineer:");

printEmployee(se);

System.out.println(" Harvard Lawyer:");

printEmployee(hl);

}

private static void printEmployee(Employee e) {

System.out.println("Salary:$"+e.getSalary());

System.out.println("Hours:"+e.getHours());

System.out.println("Vacation Days:"+e.getVacationDays());

System.out.println("Vacation form:"+e.getVacationForm());

if(e instanceof SoftwareEngineer)

{

((SoftwareEngineer)e).writecode();

}

}

}

_________________

Output:


Lawyer:
Salary:$40000.0
Hours:40
Vacation Days:15
Vacation form:pink

Software Engineer:
Salary:$55000.0
Hours:50
Vacation Days:5
Vacation form:yellow
Coding!

Harvard Lawyer:
Salary:$48000.0
Hours:40
Vacation Days:18
Vacation form:pinkpinkpink

________Could you plz rate me well.Thank You