I have a method in each of my employee subclasses that calculates their earnings and returns that value. In my main method I want to add 200 to this value if the employee has been in the workplace for over 5 years. My approach was to compare the date that the employees joined to the current date by looping through my array of different employees and checking if it has been more than 5 years. If so, I want to get the employees earnings and add 200 to it.
I get an error at employeeArray.get(i).earnings() += 200;
-> "Variable expected"
Relevant Code:
Test Class
for(int i = 0; i < employeeArray.size(); i ++){
if(employeeArray.get(i).getDateJoined().compareTo(LocalDate.of(2015, 10, 16)) <= 0)
{
employeeArray.get(i).earnings() += 200;
}
}
Employee Class
public abstract double earnings();
Example employee (boss) earnings method (Subclass to Employee)
public double earnings() {
try{
if(weeklySalary < 100){
throw new Exception();
}
}
catch (Exception lowWageException){
System.out.println();
}
return weeklySalary;
}