?? findaroundminenumber.java
字號:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package 挖雷游戲;/** * * @author Administrator */import java.awt.Color;import javax.swing.Icon;import javax.swing.ImageIcon;public class FindAroundMineNumber{ Icon 周圍無雷的圖標; public FindAroundMineNumber() { 周圍無雷的圖標=new ImageIcon("無雷.gif"); } public void 設置周圍的雷數(int i,int j,Block block[][],int 行數, int 列數) { int 雷數=0; if(block[i][j].判斷是否是雷()==false) { for(int k=Math.max(i-1,1);k<=Math.min(i+1,行數);k++) { for(int t=Math.max(j-1,1);t<=Math.min(j+1,列數);t++) { if(block[k][t].判斷是否是雷()==true) 雷數++; } } if(雷數>0) { block[i][j].周圍無雷=false; block[i][j].設置周圍有雷時的名字(""+雷數); block[i][j].設置周圍的雷數(雷數); if(雷數==1) block[i][j].label.setForeground(Color.blue); if(雷數==2) block[i][j].label.setForeground(new Color(0,100,0)); if(雷數==3) block[i][j].label.setForeground(Color.red); if(雷數>=4) block[i][j].label.setForeground(new Color(0,0,100)); } else { block[i][j].周圍無雷=true; block[i][j].設置周圍有雷時的名字(""); block[i][j].設置周圍的雷數(0); block[i][j].設置周圍無雷時的圖標(周圍無雷的圖標); } } } }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -