If you program correctly, then "nF" should never be null.
|
Code:public void clickedFood(Client c, int id, int slot) { Food nF = getIndex(FOODS,id); if(nF != null) { eat(c,id,nF,slot); return; } nF = getIndex(POTIONS,id); if(nF != null) { potion(c,id,nF,slot); return; } nF = getIndex(DRINKS,id); if(nF != null) { drink(c,id,nF,slot); return; } nF = getIndex(SPECIAL_FOODS,id); if(nF != null) { specialEat(c,id,nF,slot); return; } nF = getIndex(SPECIAL_POTIONS,id); if(nF != null) { specialPotion(c,id,nF,slot); return; } nF = getIndex(SPECIAL_DRINKS,id); if(nF != null) { specialDrink(c,id,nF,slot); return; } c.sendMessage("unable to locate food: "+id); }
well yeah i know it should never be null but in this situation it will to determine which of the 6 options it is.
i thought maybe a while would do fine like
but then that came as a problem aswell.Code:while(nF == null) { nF = getIndex(FOODS,id); nF = getIndex(DRINKS,id); nF = getIndex(POTIONS,id); }
and i could use else if but i dont see a point since returns do the same thing.
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |