samedi 15 décembre 2018

Why is my if(else if) statement being ignored?

     public void stackPower(int stackAmount)
{
          super.stackPower(stackAmount);

    if (this.amount == -1) {
        this.amount = -2;
        }
    else if (this.amount == -2) {
        this.amount = -3;
    }
    if (this.amount == -3) {
        this.amount = -4;
    }

}

During testing value goes from -1 to -2 to -4 to -6 etc.

What I want to happen: goes from -1 to -2 to -3 to -4 and then stops.

Could someone explain what I am missing here and how to fix my issue? Thanks.

Aucun commentaire:

Enregistrer un commentaire