View Single Post
  #1 (permalink)  
Old 11-05-2007, 04:44 AM
mispeed mispeed is offline
Member
 
Join Date: Nov 2007
Posts: 7
mispeed is on a distinguished road
add data into an array
hi everyone,

here is my problem. thanks for any help in advance!!!

i have an array of cells and initial number of creepers

private int initialCreeper;//get and set methods for it
private int[] cellArray = new int[numCells];
private int numCells;

private void setNumCells(int cell)
{
numCells = 10;
numCells = cell;
}
public int getNumCells
{
return numCells;
}

//here is where things go wrong
public void someMethod()
{
for(int i = 0; i < initialCreepers; i++)
{
int randomCell = (int) (Math.random() * numCells);
Cell creeper = new Cell();
cellArray[randomCell] = creeper.addCreeper();//this is a method from a different class where there is //an array of Creepers. The whole point is to add the creeper to the cell and i //know i am not doing it the right way because addCreeper() is a void method. //Not really sure how to do it though!!!??
//Thanks again
Reply With Quote
Sponsored Links