我怎样才能得到qualifiedForBonus() 的输出以在下面的toString 方法中使用。我使用“this.isBonus”作为占位符,但它不起作用,因为 isBonus 不是类中的变量。
public String eligibleForBonus(double salary){
String isBonus;
if (salary >= 40000) {
isBonus = "is";
}
else {
isBonus = "is not";
}
return isBonus;
}
}
@Override
public String toString() {
return this.forename + " " + this.surname + " (" + this.id + "): " + this.companyPosition + " at " + this.salary + " and " + this.isBonus + " eligible for bonus.";
}