Question: I need help writing a JUnit test class to test these three classes in java Employee: abstract class Employee { private static int employeeIdStatic =
I need help writing a JUnit test class to test these three classes in java
Employee:
abstract class Employee
private static int employeeIdStatic ;
private String fName;
private String lName;
private int employeeId;
public EmployeeString fName, String lName
this.fName fName;
this.lName lName;
this.employeeId employeeIdStatic;
employeeIdStatic;
public String getfName
return fName;
public String getlName
return lName;
public int getEmployeeId
return employeeId;
public void setfNameString fName
this.fName fName;
public void setlNameString lName
this.lName lName;
public String toString
return Id: employeeId fName lName;
public abstract double GetPaycheck;
SalariedEmployee:
public class SalariedEmployee extends Employee
protected double salary;
public SalariedEmployeeString fName, String lName, double salary
superfName lName;
this.salary salary;
public double GetPaycheck
return salary;
public double getSalary
return salary;
public void setSalarydouble salary
this.salary salary;
@Override
public String toString
return String.formatSalaried Base : $f; Id:d ss getSalary getEmployeeId getlName getfName;
HourlyEmployee:
public class HourlyEmployee extends Employee
private double hourlyRate;
private double hoursWorked;
public HourlyEmployeeString fName, String lName, double hourlyRate
superfName lName;
this.hourlyRate hourlyRate;
public double GetPaycheck
return hourlyRatehoursWorked;
public double getHourlyRate
return hourlyRate;
public double getHoursWorked
return hoursWorked;
public void setHourlyRatedouble hourlyRate
this.hourlyRate hourlyRate;
public void setHoursWorkeddouble hoursWorked
this.hoursWorked hoursWorked;
@Override
public String toString
return String.formatHourly: $f; Id:d ss hourlyRate, getEmployeeId getlName getfName;
CommissionedEmployee:
public class CommissionedEmployee extends SalariedEmployee
private float commissionSchedule;
private double unitsSold;
public CommissionedEmployeeString fName, String lName, float commissionSchedule, double salary
superfName lName, salary;
this.commissionSchedule new floatcommissionSchedulelength;
for int i ; i commissionSchedule.length; i
this.commissionSchedulei new floatcommissionScheduleilength;
for int j ; j commissionScheduleilength; j
this.commissionScheduleij commissionScheduleij;
public double GetPaycheck
float cs commissionSchedule;
double highestVPU ;
goes through every row
forint i ; i cslength; i
if it meets minimum units sold
ifunitsSold csi
ifcsi highestVPU
highestVPU csi;
return getSalaryhighestVPUunitsSold ;
public double getUnitsSold
return unitsSold;
public void setUnitsSoldint unitsSold
this.unitsSold unitsSold;
@Override
public String toString
return String.formatCommission: Base : $f; Id:d ss getSalary getEmployeeId getlName getfName;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
