Question: I am needing help with more testers for the Test class: Please include comments as detailed as possible and see my below question about the

I am needing help with more testers for the Test class: Please include comments as detailed as possible and see my below question about the Executive class.

Also, in the Executive class why is there a getter method but not a setter method? Does it need one and if so, please show me how. For the EmployeeTest class I just need more test programs for my classes- what I have is not sufficient and I am unsure what else to write in order to test everything as thorough as possible.

Codes:

Employee.java:

public class Employee {

private String name;

private double salary;

public Employee(String name, double salary) {

this.name = name;

this.salary = salary;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public double getSalary() {

return salary;

}

public void setSalary(double salary) {

this.salary = salary;

}

@Override

public String toString() {

return "Employee, Name=" + getName() + ", Salary=" + getSalary();

}

}

Manager.java:

public class Manager extends Employee {

private String department;

public Manager(String name, double salary, String department) {

super(name, salary);

this.department = department;

}

public String getDepartment() {

return department;

}

public void setDepartment(String department) {

this.department = department;

}

@Override

public String toString() {

return "Manager, Name=" + getName() + ", Salary=" + getSalary() + ",Department=" + getDepartment();

}

}

Executive.java:

public class Executive extends Manager {

private double bonusRatio;

public Executive(String name, double salary, String department,

double bonusRatio) {

super(name, salary, department);

this.bonusRatio = bonusRatio;

}

public double getSalary() {

return super.getSalary() * (1 + bonusRatio);

}

@Override

public String toString() {

return "Executive, Name=" + getName() + ", Salary=" + getSalary() + ",Department=" +getDepartment();

}

}

TestEmployees.java:

public class TestEmployees {

public static void main(String[] args) {

Employee dilbert = new Employee("Dilbert", 3000);

System.out.println(dilbert);

Employee pointyHairedBoss = new Manager("Dilbert Manager", 4000, "HR");

System.out.println(pointyHairedBoss );

Employee clueless = new Executive("Dilbert Executive", 5000, "Finance", 0.3);

System.out.println(clueless);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!