if(atWorldEdge()) {
getWorld().removeObject(this);
}
if(atWorldEdge()) {
getWorld().removeObject(this);
}
import greenfoot.*;
/**
* Write a description of class Munition here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Munition extends Mover
{
/**
* Act - do whatever the Munition wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
move(25.0);
if(atWorldEdge()) {
getWorld().removeObject(this);
}
if(onEnemys()) {
eat(Enemys.class);
getWorld().removeObject(this);
}
}
}
public void act()
{
move(25.0);
if(atWorldEdge()) {
getWorld().removeObject(this);
return; //this return is neccessary so the following statements do not execute
}
if(onEnemys()) {
eat(Enemys.class);
getWorld().removeObject(this);
return; //this return is not neccessary as is last statement in act()
}
}