I'm not sure if the title is right but basically I have this piece of code:
for(int i = 0; i < ArrEmployee.size(); ++i){ ArrEmployee.get(i); double provTax = ProvincialTax.calculateTax(ArrEmployee.get(i)); And this arrayList:
List<Employee> ArrEmployee = new ArrayList<>(); // array for employee objects And the ProvincialTax class is like this:
public class ProvincialTax extends Deductions { // deductions is an abstract class with the abstract method calculateTax() public double calculateTax(Employee employee) { if (employee.getAnnualGrossSalary() < 41495){ return employee.getAnnualGrossSalary()*0.16; } else if (employee.getAnnualGrossSalary() < 82985){ return employee.getAnnualGrossSalary()*0.20; } else if(employee.getAnnualGrossSalary() < 100970){ return employee.getAnnualGrossSalary()*0.24; } else return employee.getAnnualGrossSalary()*0.2575; } }
So basically my arrayList ArrEmployee stores Employee objects that have the variables:
public long EmployeeNumber; public String EmployeeName; public String LastName; public double HoursWorked; public double HourlyWage; And the HoursWorked and HourlyWage are used to calculate AnnualGrossSalary used in my ProvincialTax class. With my for loop, I'm trying to calculate the provincial tax for each object inside the ArrEmployee, but it keeps asking me to make the method calculateTax() static, but it's supposed to override an abstract method?
How do I bypass this?