Writing values to a two dimensional array
public class Colony
{
/*************
* attributes
************/
/** the 2-D array of ColonyNode objects */
private static ColonyNode[][] theColony;
/** colony height, in ColonyNodes */
private int height;
/** colony width, in ColonyNodes */
private int width;
/** the view used by this Colony */
private ColonyView colonyView;
/** create a 2D array of ColonyNode objects */
private ColonyNode theSimulation[][] = new ColonyNode[27][27]; //creates 2D array
private int x;
private int y;
/**
/***************
* constructors
**************/
/**
* Create a new Colony.
*
* @param colonyHeight: height of Colony, measured in ColonyNodes
* @param colonyWidth: width of Colony, measured in ColonyNodes
* @param view: the ColonyView this Colony will use
*/
public Colony(int colonyHeight, int colonyWidth, ColonyView view)
{
// set height and width
height = colonyHeight;
width = colonyWidth;
// set view
colonyView = view;
// create the ColonyNode objects comprising this Colony
buildColony();
}
/**********
* methods
*********/
/**
* Build the colony.
*/
private void buildColony()
{
// stores current ColonyNode
ColonyNode currentNode;
// stores ColonyNodeView for current ColonyNode
ColonyNodeView currentNodeView;
// create nodes
for (x = 0; x < width; x++)
{
for (y = 0; y < height; y++)
{
// create next node
currentNode = new ColonyNode(x,y,0,0,0,0,0,0);
// create a ColonyNode View for the current ColonyNode
currentNodeView = new ColonyNodeView();
// give current ColonyNode a reference to its ColonyNodeView
currentNode.setView(currentNodeView);
// add the current ColonyNodeView to the Colonyview
colonyView.addColonyNodeView(currentNodeView, x, y);
//add the current NodeView to the Simulation Array
addColonyView(currentNode, x, y);
//create relationship for Simulation class
//Simulation.addSimulationColonyNodeView(x, y);
// this is only here to prove the colony has been created;
// DO NOT make any nodes visible here
//****Move this to Simulation class
//currentNodeView.showNode();
//initialize colony to show only the start-up nodes
if
(x >= 12 && x <=14 && y >= 12 && y <=14)
currentNodeView.showNode();
else
currentNodeView.hideNode();
} //end nested for loop
} //end for
} //end buildColony
public void addColonyNode(ColonyNode node, int x, int y)
{
//theSimulation[][]= x,y;(this code commented out)
theSimulation[][]= currentNode; <<<<<<<<<<<<<ERROR HERE
}// end addColonyNode method
}

