Conditional Statements

Simple If Statement

Sometimes you have an action (or several actions) that should be done only under certain conditions.

For example, if a fish is at the wall of an aquarium, it needs to change direction before it can move forward.

    if ( fish.atWall() == true )
if ( <boolean-expression> )
    <the conditional statement(s)>

Alyce Brady, Kalamazoo College