How can I make a 12 X 12 grid where I can have multiple inhabitants in a square.
Do I put a container in the cell?
What would the code look like for this 12 x 12 grid
I have know idea what to do
I have this code already for a board game,but do not know what to do next
public class Board {
private static final int Row = 12;
private static final int Column = 12;
private static final int RowHeight = 50;
private static final int ColumnWidth = 50;
int grid [][] = new int [Row][Column];
//...
}
grid container12 x 12 grid
Page 1 of 1
1 Replies - 1653 Views - Last Post: 15 December 2008 - 07:50 PM
Replies To: grid container
#2
Re: grid container
Posted 15 December 2008 - 07:50 PM
I guess it depends on what you mean by inhabitants. If you are talking about a grid style layout manager for a GUI where each section might have multiple buttons or controls, then you would actually make a 2D array of JPanels.
If you are talking about objects, you would create a class, define its various parts, then create a 2D array of that object.
So lets say I have a square for use in a chess game. I would first define a square class that would have things like width, height, color and maybe if it has a piece on it right now. Then I would create a 2D array of square objects...
This will now allow each slot of the board to have an object which can contain various data members like variables, functions, inner classes etc.
Hopefully this is what you were referring to.
If you are talking about objects, you would create a class, define its various parts, then create a 2D array of that object.
So lets say I have a square for use in a chess game. I would first define a square class that would have things like width, height, color and maybe if it has a piece on it right now. Then I would create a 2D array of square objects...
// Create a 2D Board of 64 square objects. square board[][] = new square[8][8];
This will now allow each slot of the board to have an object which can contain various data members like variables, functions, inner classes etc.
Hopefully this is what you were referring to.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|