lundi 22 décembre 2014

What's wrong with my return statement?

Why this code is wrong ? When I change "else if(this.power >= p)" into only "else", it's right. Can anybody give me a hint?



public boolean useBattery(double p) {
if(this.power < p) {
this.power = 0.0;
return false;
} else if(this.power >= p) {
this.power = this.power - p;
return true;
}
}

Aucun commentaire:

Enregistrer un commentaire