Hi, I'm practicing a turtorial on the Joy of Code#17. When I paste the constructor public boolean atWorldEdge() into my code and compile I get an erro message : illegal start of expression. can you help? what have I done wrong?
public class Ball extends Actor
{
/**
* ACT METHOD - do whatever the Ball wants to do. This METHOD is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
move(4); //this is the move(); method from the ACTOR CLASS
if (atWorldEdge()){ // atWorldEdge (); is a method from the ACTOR CLASS. We use the IF STATEMENT
// when we are testing a condition.
turn(153); // turn() is another method from the ACTOR CLASS that holds information in
// parameter list in DEGREES
}
/**
* TEST if we are close to one of the edges of the world. RETURN true if we are
*/
public boolean atWorldEdge()
{
if(getX() < 10 || getX() > getWorld().getWidth() - 10)
return true;
if(getY() < 10 || getY() > getWorld().getHeight() - 10)
return true;
else
return false;
}
}