Test review
When? Monday 9/27 in class
Know Greenfoot How many classes? Top-most classes? What does each button do? Lowest child class?
Read code public class Crab extends Animal { public void act( ) { checkAtEdge( 12 ); randomTurn( ); eatWorm( ); checkKeyPress( ); move( ); } // end act() method Class name? Class parent? Method name? Method return type? Method calls? Method that contains information to be passed? Comment?
checkAtEdge( 12 );What is this? What info is sent TO the method? What TYPE of info?
import greenfoot:What is this? Library name Give an example of it’s use
Greenfoot.getRandomNumber( limit ); How would you get a random number in the range ? Write an if statement to do something 25% of the time.
If statements and greenfoot Write code to... Do something 45% of the time Check if the left cursor key is pressed Turn 17 degrees at the world edge Eat a worm, including the if statement
Bracket rules Follow class definitions, method definitions, if statements Always paired { }
Semi-colon rules Not placed where brackets are used (class and methods definitions, if statements) Everywhere ELSE
import greenfoot.*; // Kills aliens public class Halo extends Actor { public void act() { setLocation( 100, 200 ) ; if( getSize( ) < 10 ) { killAlien( ); } move( ); } public void killAlien( ) { eat( Alien.class ); } How many steps? How many methods defined? How many methods called?
Identify errors... public class void Animal extends Crab ( ) { public boolean act( ); { if ( x < 10 ) { move; }