Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int checkForIslands(Tile[][] tiles) {
- int islands = 0;
- //create temparray and init
- Tile[][] t = new Tile[tiles.length][tiles[0].length];
- for(int i = 0; i < t.length;i++) {
- for(int j = 0; j < t[0].length; j++) {
- t[i][j] = new Tile(i,j,TileType.EMPTY);
- }
- }
- //Copy TileType
- for(int i = 0; i < t.length;i++) {
- for(int j = 0; j < t[0].length; j++) {
- t[i][j].setType(tiles[i][j].getType());
- }
- }
- for(int i = 0; i < t.length; i++) {
- for(int j = 0; j < t[0].length; j++) {
- islands += checkNeighbours(i,j,t);
- }
- }
- return islands;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement