selection structures in Jeroo! if, if else, if, else if, else if, else
if else ladder - a multi-way selection Rules: each condition must be in parentheses no semicolon after the parentheses no limit on the number of else if blocks the final else branch is option
if(Louisa.isFlower(AHEAD) { Louisa.hop(); Louisa.pick(); } else if(Louisa.isNet(AHEAD) { LouisA.toss(); } else if(Louisa.isWater(AHEAD) { Louisa.plant(); } else {hop(); turn(RIGHT); }
COMPOUND CONDITIONS OPERATORJEROO SYMBOL MEANING NEGATION!NOT CONJUNCTION&&AND DISJUNCTION||OR
! EXAMPLE !Bob.isNet(AHEAD) //there is not a net ahead.
EXAMPLE Bob.hasFlower() && Bob.isClear(LEFT) //Bob has at least one flower and there is nothing in the cell immediately to the left.
&& EXAMPLE Bob.isFacing(WEST) && (!Bob.isNet(AHEAD) Bob is facing west and there is no net ahead.