Code:
public class fly extends Actor
{
public fly()
{
setColor(Color.BLACK);
}
public fly(Color flyColor)
{
setColor(flyColor);
}
public void act()
{
if (canMove())
{
move();
}
else
{
turn();
}
}
public void move()
{
if (getGrid() == null)
{
return;
}
ArrayList<Actors> actors = getActors();
processActors(actors);
ArrayList<Location> moveLocs = getMoveLocations();
Location loc = selectMoveLocation(moveLocs);
makeMove(loc);
}
public ArrayList<Actor> getActors()
{
return getGrid().getOccupiedLocations(getLocation());
}
public void processActors(ArrayList<Actor> actors)
{
for (Actor a : actors)
{
if (!(a instanceof Rock) && !(a instanceof Critter) && !(a instanceof fly) && !(a instanceof Bug))
{
a.removeSelfFromGrid();
}
}
}
public ArrayList<Location> getMoveLocations()
{
return getGrid().get //NEED HELP HERE!
}
public Location selectMoveLocation(ArrayList<Location> locs)
{
int n = locs.size();
if (n == 0)
{
return getLocation();
}
int r = (int)(Math.random() * n);
return locs.get(r);
}
public void makeMove(Location loc)
{
if (loc == null)
{
removeSelfFromGrid();
}
else
{
moveTo(loc);
}
}
}
Thanks
Comment