Results 1 to 2 of 2
Thread: help with gridworld?
- 04-28-2011, 09:55 PM #1
Member
- Join Date
- Apr 2011
- Posts
- 1
- Rep Power
- 0
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.Java Code:package info.gridworld.actor; import info.gridworld.grid.Location; import java.util.ArrayList; import info.gridworld.grid.Grid; import java.awt.Color; public class Pawn extends Critter { public Grid<Pawn> grid; public Location location; public int direction; public Color color; public Pawn() { color = Color.WHITE; direction = Location.NORTH; grid = null; location = null; } public void act() { if (getGrid() == null) return; ArrayList<Actor> actors = getActors(); processActors(actors); ArrayList<Location> moveLocs = getMoveLocations(); Location loc = selectMoveLocation(moveLocs); makeMove(loc); } public ArrayList<Location> getMoveLocations() { ArrayList<Location> locs = new ArrayList(); locs.add(getLocation().getAdjacentLocation(direction)); return locs; } public Location selectMoveLocation(ArrayList<Location> locs) { int n = locs.size(); if (n == 0) return getLocation(); for(Location a: locs) if ((a.compareTo(getLocation())<2)) return a; return getLocation(); } public void makeMove(Location loc) { if (loc == null) removeSelfFromGrid(); else moveTo(loc); } }
- 04-28-2011, 10:10 PM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
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.
Similar Threads
-
Object Construction ends Program in GridWorld
By BJ1110 in forum Advanced JavaReplies: 9Last Post: 02-04-2011, 04:02 PM -
Implementing "Game Over" in Minesweeper game based on Gridworld framework.
By JFlash in forum New To JavaReplies: 2Last Post: 08-05-2010, 04:49 AM -
Need gridworld help
By robertbob in forum New To JavaReplies: 2Last Post: 05-03-2010, 05:18 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks