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

Lab 5-Word ding1 Heading2 Tdleb ubtle Em EmphasisnteeEStron Quote Intese Q Sultl

ID: 3751621 • Letter: L

Question


Lab 5-Word ding1 Heading2 Tdleb ubtle Em EmphasisnteeEStron Quote Intese Q Sultle Re Stytes Given the Employee class and the Lawyer class above a. Write an employee class SoftwareEngineer to accompany the other employees. SoftwareEngineers work 10 more hours(50 hours/week) they make $55,000 ($15,000 more than others), they get half as much vacation only 5 days), and they have an additional method named uriteCode that prints "Coding!" 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 three of the lawyer's forms to go on vacation. That is, the getVacationForm method should return "pinkpinkpink". (If the normal Lawyer's vacation form ever changed, the HarvardLauver' should as well. For example, if Lawyer's vacation form changed to "red", the HarvardLawyer's should return "redredred") Use the super keyword to interact with the Lawyer superclass as appropriate Write a client class called Employee Client that creates objects of Lawyer, SoftwareEngineer and HardvardLauyer class in the main method. Write a method called printEmplovee) 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 SoftwareEngineer object. Call printEmplovee method from main method c. Example output for Lawyer object Lawyer Salary: $40000 Hours: 40 Vacation days: 15 Vacation form: pink

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