To extend a class we must put the runner class and the new class into a folder together. This folder should be in the projects folder. In the following example the Bugs class extends the Bug class.
import info.gridworld.actor.ActorWorld; import info.gridworld.actor.Bug; import info.gridworld.actor.Rock; import info.gridworld.actor.Flower; import info.gridworld.actor.Critter; public class BugRunner2 { public static void main(String[] args) { ActorWorld world = new ActorWorld(); world.add(new Bug()); world.add(new Rock()); world.add(new Flower()); world.add(new Critter()); world.add(new Bugs()); world.show(); } } _______________ import info.gridworld.actor.Bug; import info.gridworld.actor.Actor; import info.gridworld.grid.Grid; import info.gridworld.grid.Location; import java.awt.Color; public class Bugs extends Bug {public Bugs() { super(); setColor(Color.BLUE); } public void turn() { setDirection(getDirection() + Location.HALF_LEFT); } }