我是 Java 新手,目前正在从事一个小型初学者项目。我应该构建一个扫雷 Java 游戏。但是,我一直在寻找将游戏板上的整数“0”更改为空白。也许你们可以帮我解决这个问题。谢谢
public class Game {
private Gameloop gameloop;
boolean finish = false;
boolean win = false;
int turn=0;
public Game(){
gameloop = new Gameloop();
Play(gameloop);
}
public void Play(Gameloop gameloop){
do{
turn++;
System.out.println("There are a total of 10 mines in the mine field");
gameloop.show();
finish = gameloop.checkLocation();
if(!finish){
gameloop.numberOfMines();
finish = gameloop.win();
}
}while(!finish);
if(gameloop.win()){
System.out.println("You Win!");
gameloop.showMines();
} else {
System.out.println("Game Over!");
gameloop.showMines();
}
}
public class Gameloop {
private int[][] mines;
private char[][] boardgame;
private int Line, Column;
Random random = new Random();
Scanner input = new Scanner(System.in);
public Gameloop (){
mines = new int[12][12];
boardgame = new char[12][12];
startMines();
randomFillGrid();
fillTips();
startBoard();
}
public boolean win(){
int count=0;
for(int line = 1 ; line < 11 ; line++)
for(int column = 1 ; column < 11 ; column++)
if(boardgame[line][column]=='_')
count++;
if(count == 12)
return true;
else
return false;
}
猛跑小猪
慕工程0101907
绝地无双
RISEBY
拉丁的传说
相关分类