vendredi 6 avril 2018

Break Out of If Else

OK, i know this question is kind of strange but the result i am getting is also strange, Apparently, i have an if else system to calculate something, it is like this

if (civilianDeadCount >= 20 || policeDeadCount >= 15) 
        {

            starCount = 5;
            return;
        } else if (civilianDeadCount >= 15 || policeDeadCount >= 10) 
        {

            starCount = 4;
            return;
        } else if (civilianDeadCount >= 8 || policeDeadCount >= 5) 
        {

            starCount = 3;
            return;
        } else if (civilianDeadCount >= 5 || policeDeadCount >= 2) 
        {

            starCount = 2;
            return;
        } else if (civilianDeadCount >= 2 || policeDeadCount >= 1) 
        {

            starCount = 1;
            return;
        } 
}

The Problem is i need to get out the if else system or even the function when one of these conditions gets true. At the moment if the third system is true it cascades through all the rest of the conditions

Aucun commentaire:

Enregistrer un commentaire