samedi 31 octobre 2015

Undefined operator for if function - Java

I am trying to write a simple if function that calculates if someone is eligible for a bonus or not. This is done in an "Employee" class that has fields:

  private int             id       = 0;
  private String          forename = null;
  private String          surname  = null;
  private Salary          salary;
  private CompanyPosition companyPosition;

Here is the IF :

public boolean eligibleForBonus(){

boolean isEligible = true;

if ( salary >= 40000) {
  isEligible = true;
  }
return isEligible
}

Salary is another class with a field

private double salary = 0.0;

(also has all getters and setters defined)

HOWEVER - i get an error on the line with the IF, that:

" The operator >= is undefined for the argument type Salary, int

Can someone help? Thank you

Aucun commentaire:

Enregistrer un commentaire