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: |
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) |
Jeroo Kim = new Jeroo(8); Specify the flowers |
Location: (0,0) |
Jeroo Kim = new Jeroo(3,4); Specify the location |
Location: (3,4) |
Jeroo Kim = new Jeroo(3,4,WEST); Specify location and direction |
Location: (3,4) |
Jeroo Kim = new Jeroo(3,4,8); Specify location and flowers |
Location: (3,4) |
Jeroo Kim = new Jeroo(3,4,SOUTH,8); Specify all attributes |
Location: (3,4) |
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.
|