lundi 28 septembre 2015

Sorting 4 constants with 2 if -thens

I'm having troubles trying to think of a way to sort these 4 "costs". My end goal is to not have two identical if-then statements inside the method, this example is just a quick mockup. I'm sure it's simple code that I'm missing.

int discount_InsideZone;
int discount_OutsideZone;
int insideZone;
int outsideZone;

static int something(boolean discounted, int startzone, int endzone)
{
/* if 
   discounted == true && startzone == endzone Return discount_InsideZone;
   discounted == true && startzone <> endzone Return discount_OutsideZone;
   discounted == false && startzone == endzone Return insideZone;
   discounted == false && startzone <> endzone Return outsideZone;
*/
}

Aucun commentaire:

Enregistrer un commentaire