Hi
I have the below code which is to generate a 2D Array... The problem is that I need to populate it by part of array... not by complete array.
For example...
map[1][0] = 1;
map[1][1] = 1;
map[1][2] = 1;
map[3][5] = 2;
map[3][5] = 2;
map[3][5] = 2;
map[6][5] = 3;
map[6][6] = 3;
map[5][5] = 3;
Whenever I am trying to populate the individual element (or any element for that matter), an error is returned saying 'Incompatible types - found int but expected Map'. I know it has something to do with the constructor but I need this as I need the array to be widely available to a number of classes
All the other values can be the default 0 (this would make things easy!). The idea behind it is I need to create a 'map' where the array elements represent a group of individuals and Access Control requests are passed around the determine if the group of individuals can or cannot move to. Essentially its a game like battleships, but more complex
Thanks
I have the below code which is to generate a 2D Array... The problem is that I need to populate it by part of array... not by complete array.
For example...
map[1][0] = 1;
map[1][1] = 1;
map[1][2] = 1;
map[3][5] = 2;
map[3][5] = 2;
map[3][5] = 2;
map[6][5] = 3;
map[6][6] = 3;
map[5][5] = 3;
Whenever I am trying to populate the individual element (or any element for that matter), an error is returned saying 'Incompatible types - found int but expected Map'. I know it has something to do with the constructor but I need this as I need the array to be widely available to a number of classes
All the other values can be the default 0 (this would make things easy!). The idea behind it is I need to create a 'map' where the array elements represent a group of individuals and Access Control requests are passed around the determine if the group of individuals can or cannot move to. Essentially its a game like battleships, but more complex
Code:
class Map
{
private Map[][] map;
public Map()
{
Map map[][] = new Map[8][10];
}
public void populateMap(Map[][] map)
{
map[1][0] = 1;
}
public Map getMapData(int x, int y)
{
return map[x][y];
}
}
Comment