Summary of Jeroo using Java

Action Methods
hop();
hop(n); where n > 0
pick
();
plant();
toss();
give( relative_direction);
turn( relative_direction );
Boolean methods return true or false.
hasFlower()
isFacing(
compass_direction )
isFlower( relative_direction )
isJeroo( relative_direction )
isNet( relative_direction )
isWater(
relative_direction )
isClear( relative_direction )

Directions:
Relative Directions: LEFT, RIGHT, AHEAD, HERE
Compass Directions: NORTH, SOUTH, EAST, WEST

Every program needs a main method:
method main( )
{ all of your code goes in here }
Custom Methods:
method yourChoice( )
{ ... }

Constructors

Attributes

Jeroo Kim = new Jeroo();          

Accept default attributes

Location: (0,0)
Direction: EAST
Flowers: 0

Jeroo Kim = new Jeroo(8);          

Specify the flowers

Location: (0,0)
Direction: EAST
Flowers: 8

Jeroo Kim = new Jeroo(3,4);          

Specify the location

Location: (3,4)
Direction: EAST
Flowers: 0

Jeroo Kim = new Jeroo(3,4,WEST);          

Specify location and direction

Location: (3,4)
Direction: WEST
Flowers: 0

Jeroo Kim = new Jeroo(3,4,8);          

Specify location and flowers

Location: (3,4)
Direction: EAST
Flowers: 8

Jeroo Kim = new Jeroo(3,4,SOUTH,8);          

Specify all attributes

Location: (3,4)
Direction: SOUTH
Flowers: 8

Loops and Decisions:
while(condition is true) 
    {repeat these statements }


if(condition is true)
   { do these statements }
else
   { choose these instead }
 

A condition is a Boolean expression -- an expression that is either true or false.

  • There are 3 Boolean operators: !, &&, ||
    They represent "not", "and", and "or", respectively.
  • Without parentheses to indicate otherwise, every "not" operator will be evaluated 1st, "and" operators will be evaluated 2nd, and "or" operators will be evaluated 3rd.