View Single Post
  #3 (permalink)  
Old 11-05-2007, 10:33 AM
mispeed mispeed is offline
Member
 
Join Date: Nov 2007
Posts: 7
mispeed is on a distinguished road
yea sorry if it was unclear...
i'll try to explain!

Code:
class One { private int initialFood = 30; private int numCreepers = 30; private int birthWeightCreepers = 3; //here i'm not sure which is correct private Cell[] cell = new Cell[9]; //or: private int[] cell = new int[9]; //get and set methods for food, creepers, birthWeight //initialize game method public void methodName() { //add food to the cells for(i = 0; i < initialFood; i++) { //find a cell - random NUM between 0 and numberOfCells randomNum = (int) (Math.random() * numCells); //add food to the cell cell[index] = randomNum; // not sure what would happen when index goes //past 9, but i couldn't think of anything else:confused: } public void methodName2() { //add creepers to the cells for(index = 0; index < numCreepers; i++) { //random num: 0 and numCells randomNum = (int) (Math.random() * numCells); //tell the cell to add a Creeper(pass in the birth weight) //yea here i'm confused because addCreeper is a method in Cell class , //so then the cell[] should be of type Cell //i think to access the method! } } }//end class class Cell { private amount of food; private array of creepers//the array within a cell //add a creeper method public void addCreeper { //for each element in the array of creepers for(index = 0; index < creepers.length; index++) { //if not null if(creepers[index] != null) { //create a creeper Creeper theCreeper = new Creeper();//Creeper has get and set //methods for age and weight and thats all //set birth weight and age(age = 1; weight given by caller) theCreeper.setAge(1);//set age //update the element with a ref. to the Creeper } //end if }//end for } } }//this is getting too long sorry about that! i think it would give you a better //idea of what's happening!
Reply With Quote