You're calling this method within itself, causing a StackOverflow error.
public void moveTo(Location newLocation)
{
Location loc = new Location(getGrid().getNumCols(), getGrid().getNumRows());
moveTo(loc);
sideLength = 0;
}
This is the wrong method. This should be in the move()
method. The moveTo
method takes a location and moves to that location. This should not be overriden.
Change it to:
public void move(Location newLocation)
{
Location loc = new Location(getGrid().getNumCols(), getGrid().getNumRows());
moveTo(loc);
sideLength = 0;
}