ADD file via upload

main
pyxfrvnbe 1 year ago
parent e0b28d0761
commit ca48be9db5

@ -0,0 +1,52 @@
package keshe;
import java.util.Random;
/**
*
* MapTool.java
**/
public class MapTool {
//创建数字地图1
public static int[][] createMap1() {
int[][] map = new int[10][10];
Random rand = new Random();
for (int i = 0; i < map.length; i++) {
for (int j = 0; j < map[i].length; j++) {
map[i][j] = rand.nextInt(9) + 1;
}
}
return map;
}
//创建数字地图2
public static int[][] createMap2() {
int[][] map = new int[15][15];
Random rand = new Random();
for (int i = 0; i < map.length; i++) {
for (int j = 0; j < map[i].length; j++) {
map[i][j] = rand.nextInt(14) + 1;
}
}
return map;
}
//创建数字地图3
public static int[][] createMap3() {
int[][] map = new int[20][20];
Random rand = new Random();
for (int i = 0; i < map.length; i++) {
for (int j = 0; j < map[i].length; j++) {
map[i][j] = rand.nextInt(19) + 1;
}
}
return map;
}
//消除相同的方块,打印消除方块的位置
public static int[][] removed(int[][] map, int pi, int pj, int ci, int cj) {
if (map[pi][pj] == map[ci][cj] && (pj != cj || pi != ci)) {
System.out.println("消除map[" + ci + "][" + cj + "]map[" + pi + "][" + pj + "]");
map[pi][pj] = 0;
map[ci][cj] = 0;
}
return map;
}
}
Loading…
Cancel
Save