Presentation is loading. Please wait.

Presentation is loading. Please wait.

Selection structures in Jeroo! if, if else, if, else if, else if, else.

Similar presentations


Presentation on theme: "Selection structures in Jeroo! if, if else, if, else if, else if, else."— Presentation transcript:

1 selection structures in Jeroo! if, if else, if, else if, else if, else

2 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

3 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); }

4 COMPOUND CONDITIONS OPERATORJEROO SYMBOL MEANING NEGATION!NOT CONJUNCTION&&AND DISJUNCTION||OR

5 ! EXAMPLE !Bob.isNet(AHEAD) //there is not a net ahead.

6 EXAMPLE Bob.hasFlower() && Bob.isClear(LEFT) //Bob has at least one flower and there is nothing in the cell immediately to the left.

7 && EXAMPLE Bob.isFacing(WEST) && (!Bob.isNet(AHEAD) Bob is facing west and there is no net ahead.


Download ppt "Selection structures in Jeroo! if, if else, if, else if, else if, else."

Similar presentations


Ads by Google