I'm writing a bug called HomerBug.
HomerBug is a subclass of Bug.
HomerBug chooses a DumbRainbowBug in the Grid.
If there are no DumbRainbowBugs, it does nothing.
Otherwise it takes one step closer to the DumbRainbowBug every step, plowing over everything in its path, until it kills the DumbRainbowBug.
I have already written DumbRainbowBug, essentially I need help establishing the location of 1 or all of the DumbRainbowBugs in the grid. I want to call the getLocation() method from DumbRainbowBug and use that location in HomerBug, but I can't seem to do it. Any and all help is appreciated, thanks.
Here is my fail code thus far:
import info.gridworld.actor.Bug; import info.gridworld.grid.Grid; import info.gridworld.grid.Location; import info.gridworld.actor.Actor; import info.gridworld.grid.*; import java.util.*; import java.awt.Color; public class HomerBug extends Bug { public HomerBug() { setColor(Color.PINK); } public void act() { //Location loc = new Location((DumbRainBowBug)DumbRainBowBug.getLocation()); //Location loc = new Location(DumbRainBowBug.getLocation()); //Location z = getLocation(); //System.out.println(z.getDirectionToward(loc)); } }