help with gridworld?
I'm trying to make a "Pawn" in gridworld ... i have some ways to go but for now I just want it to show up on the grid... whenever i run the file it says
C:\Users\Samir\javaprograms\chess\GameRunner.java: 13: cannot access Pawn
bad class file: C:\Users\Samir\javaprograms\chess\Pawn.java
file does not contain class Pawn
Please remove or make sure it appears in the correct subdirectory of the classpath.
world.add(new Location(1, 1), new Pawn());
the code for the Pawn is this:
Idk if this matters or not... but java is not making a .class for this prog whenever i run it for some reason... help please.
public class Pawn extends Critter
public Grid<Pawn> grid;
public Location location;
public int direction;
public Color color;
color = Color.WHITE;
direction = Location.NORTH;
grid = null;
location = null;
public void act()
if (getGrid() == null)
ArrayList<Actor> actors = getActors();
ArrayList<Location> moveLocs = getMoveLocations();
Location loc = selectMoveLocation(moveLocs);
public ArrayList<Location> getMoveLocations()
ArrayList<Location> locs = new ArrayList();
public Location selectMoveLocation(ArrayList<Location> locs)
int n = locs.size();
if (n == 0)
for(Location a: locs)
public void makeMove(Location loc)
if (loc == null)
You declare Pawn to be part of the info.gridworld.actor package. But you the have the source file in C:\Users\Samir\javaprograms\chess\ next to GameRunner.java. The two things - package and directory location - have to match.
Put Pawn.java at the same place as Critter.java (next to GameRunner.java?) and see what happens, and make the package declarations the same for both classes. If you continue to hit problems describe the exact layout of the files involved in this program. And the commands you are using to compile and run the program.