public class Landscape { private int width = 0; private int height = 0; private Agent[] agents = null; private int densities [] = null; public void calcDensities() { densities = new int [width*height]; for (int i = 0; i < agents.length; i++) { densities[(agents[i].getY()*width) + agents[i].getX()]++; } } // The following two methods added. public void setDensities (int[] densities) { this.densities = densities; } public int[] getDensities() { return densities; } public int getDensity(int x, int y) { return densities[(y*width) + x]; } public void setAgents (Agent[] agents) { this.agents = agents; } public void setWidth(int width) { this.width= width; } public int getWidth() { return width; } public void setHeight(int height) { this.height = height; } public int getHeight() { return height; } }