DungeonMaze dungeon = new DungeonMaze();
System.out.println("\nCell " + choice + "is Cell #" + dungeon.CellArrayTester(dungeon.populateGrid(r,c), choice)); <---- this one
Choice is an int specified through input.
R = rows, specified through input.
C = columns, specified through input.
public static Object[] populateGrid(int numRows, int numCols) {
Cells[] cell = new Cells[(numRows*numCols)];
/*System.out.println("Rows = " + numRows);
System.out.println("Cols = " + numCols);
System.out.println("Rows x Cols = " + numRows*numCols);*/
for(int p = 0; p < numRows*numCols; p++) {
colNo++;
numCells++;
if(colNo == numCols + 1 && colNo != numCols && rowNo < numRows) {
colNo = 1;
rowNo++;
System.out.print(" ;Row #" + rowNo + "\n[" + colNo + "]");
}
else if(colNo == numCols && rowNo == numRows - 1) {
rowNo++;
System.out.print("[" + colNo + "]" + " ;Row #" + rowNo);
}
else System.out.print("[" + colNo + "]");
// Make a new cell on every go-around - array of objects with reference number for each cell
//Cells newCell = new Cells();
// Set cell's number
cell[numCells].setCellNumber(numCells); //newCell.setCellNumber(numCells);
// Get cell's coordinates
//newCell.setPosX(colNo);
//newCell.setPosY(rowNo);
}
return cell;
} public static int CellArrayTester(Cells[] cell, int choice) {
return cell[choice].getCellNumber();
}public class Cells {
static int posx, posy;
static int cellNumber;
public static void setCellNumber(int number) {
cellNumber = number;
}
public static int getCellNumber() {
return cellNumber;
}
}