亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? mine.java

?? Java掃雷程序,主要實現了基本的算法
?? JAVA
字號:
// File Name:    Mine.java
// Author:       TianBaideng		Student Number: 3005218107
// Class Day:    thursday			Class Number: 4		Class Year: 2005
// Email:        tian_bai_deng@126.com
// Assignment number:  4
// Description:  this class is the major class which create a window,buttons,
//				 and add icon on the button,and has a iner class,Buttonhandler,
//				 which is to deal with mouse click event,in addition,the main 
//				 arithmetic is in method clear()

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class Mine extends JFrame{
	
	//store buttons
	private Button buttons[][];
	
	//the mine map,include 0: none mine,1:mine
	private Map map[][];
	private Container container;
	private Icon icon [];
	private JLabel label;
	
	//the number of the remaining mines
	private int remain ;
	
	//record the buttons position marked with flag
	private int record[];
	
	//count for record
	private int r;
	
	//for remain mine
	private boolean result;
	
	//class Mine constructor which will display the window and create 10*10
	//buttons which will add a addMouseListener then call method initial() 
	//that I have define below to initialize the window
	public Mine()
	{
	   super("Mine Sweeper");
	   
	   //record the butons that is marked with flag 
	   record = new int [20];
	   container = getContentPane();
	   
	   //the whole container is  BorderLayout
	   container.setLayout(new BorderLayout());
	   //create label
	   label = new JLabel();
	   
	   //contain the buttons
	   JPanel pan = new JPanel();
	   
	   //contain the label
	   JPanel flow = new JPanel();
	   
	   flow.setLayout(new FlowLayout());
	   flow.add(label);
	   
	   pan.setLayout(new GridLayout(10,10,0,0));
	   
	   //add the label in the top and buttons in the bottom
	   container.add(flow,BorderLayout.NORTH);
	   container.add(pan,BorderLayout.CENTER); 
	   
	   //image sets
	   String[] name = {"none.gif","1.gif","2.gif","3.gif","4.gif","5.gif","6.gif",
			   			"7.gif","8.gif","mine.gif","flags.gif","d.gif","problem.gif"};
	   //create icons
	   icon = new Icon[13];
	   for(int i=0;i<13;i++)
		   icon[i] = new ImageIcon(name[i]);
	   
	   //create 10*10 buttons  
	   buttons = new Button [10][10];
	   
	   //create map
	   map = new Map[10][10]; 
	   Buttonhandler handler = new Buttonhandler();
	  
	   //add 100 buttons
	   for(int i=0;i<10;i++)
	   {
		   for(int j=0;j<10;j++)
		   {
			   map[i][j] = new Map();
			   buttons[i][j] = new Button();
			  
			   //every button add a listener
			   buttons[i][j].addMouseListener(handler);
			   
			   //add the button in the pan which style is grid
			   pan.add(buttons[i][j]);
		   }
	   }
	   //initialize
	   initial();
	   setSize(430,480);
	   
	   //set the window not resizable
	   setResizable(false);
	   setVisible(true);
	}// end construct method 
	
	//initialize the window such as set button icon ,randomly set mines
	void initial()
	{
		result = true;
		 remain = 10;
		 r = 0;
		 label.setText("Mines remaining"+remain);
		 label.setForeground(Color.BLUE);
		 
		 //initialize buttons with icon and buttons with flags  
		 for(int i=0;i<10;i++)
			 for(int j=0;j<10;j++)
			 {
				 map[i][j].mine = 0;
				 map[i][j].flag = 0;
				 buttons[i][j].setIcon(icon[11]);
				 buttons[i][j].Lclick = 0;
				 buttons[i][j].Rclick = 0;
			     buttons[i][j].flag = 0;
			}
		 
		   //Randomly add 10 Mines
		   Random  random = new Random();
		   for(int i=0;i<10;i++)
		   {
			   int n= random.nextInt(100);
			   while(map[n/10][n%10].mine!=0)
			   {
				   n=random.nextInt(100);
			   }   
			   map[n/10][n%10].mine=1;
		   }
	}// end method initial 
	
	//spread the none mine area,this method is a recursion method
	public void clear(int x,int y)
	{
		//guarantee the area in the map 
		if(x>=0&&x<10&&y>=0&&y<10)
		{
			//insure the area is not referenced
			if(map[x][y].flag ==0&&buttons[x][y].flag == 0)
			{
				//mark the area that can not be clicked 
				map[x][y].flag = 1;
				buttons[x][y].flag =1;
				buttons[x][y].Lclick = 1;
				
				//get the number of mines surrounding the area
				int c = search(x,y);
				
				//if no mine,then to spread this area and to check its surrounding area
				if(c == 0)
				{
					buttons[x][y].setIcon(icon[0]);
					for(int i=x-1;i<=x+1;i++)
						for(int j=y-1;j<=y+1;j++)	
						{
							clear(i,j);
						}
				}
				//if has mines,mark the number of mines,then ends
				else
					buttons[x][y].setIcon(icon[c]);	
			}
		}
	}// end method clear
	
	// exposure the mine area
	void sweeper()
	{
	   for(int i=0;i<10;i++)
		   for(int j=0;j<10;j++)
			   if(map[i][j].mine == 1)
				   buttons[i][j].setIcon(icon[9]);
	}// end method sweeper
	
	//found the number of mines in 8 directions 
	int search(int x,int y)
	{
		int count =0;
		for(int i=x-1;i<=x+1;i++)
			for(int j=y-1;j<=y+1;j++)
			{
				if(i>=0&&i<10&&j>=0&&j<10)
					if(map[i][j].mine == 1)
					count ++;
			}
		return count;
		
	} //end method search
	
	//deal with right button event
	void rbutton(int i,int j)
	{
		//deal with which  icon is displayed
		//0: the original icon is displayed
		//1: the flag icon is displayed and mark this button
		//   the left button can not click 
		//2: the problem icon is displayed and cancel the mark
		//   that the left button can click 
		
		//left button is not clicked
		
		//the right click number increase
		buttons[i][j].Rclick++;
		buttons[i][j].flag = 1;
		switch(buttons[i][j].Rclick%3)
		{
			case 0:
				buttons[i][j].flag = 0;
				buttons[i][j].setIcon(icon[11]);
				break;
			case 1:
				if(result)
				{
					if(remain>0)
					{
						record[r] = i;
						r++;
						record[r] = j;
						r++;
					
						buttons[i][j].flag = 1;
						buttons[i][j].setIcon(icon[10]);
						remain--;
						label.setText("Mines remaining"+remain);
						//remaining mine is none
						if(remain == 0 )
						{	
							//check whether all of the flag buttons is mine
							for(int k=0;k<10;k++)
							{
								if(map[record[2*k]][record[2*k+1]].mine ==0)
								{
									result = false;
									break;
								}
							}
							if(result)
							{
								JOptionPane.showMessageDialog(null,"You Win!!" );
						
								//reset
								initial();
							}
							else
								JOptionPane.showMessageDialog(null,"Miss mark!!!!" );
						
						}
					}
				}
				else
				{
					buttons[i][j].Rclick--;
					JOptionPane.showMessageDialog(null,"Miss mark!!!!" );
				}
				break;
			case 2:
				if(remain>0 || !result)
				{
					r--;
					r--;
					buttons[i][j].flag = 0;
					remain++;
					label.setText("Mines remaining"+remain);
					buttons[i][j].setIcon(icon[12]);
					result = true;
				}
				break;
		}
		//if(remain == 0)
	} //end method rbutton
	
	//deal with left button event
	void lbutton(int i,int j)
	{
		
		//this button has not been clicked
		if(buttons[i][j].flag == 0)
		{
			//mark the button 
			buttons[i][j].Lclick = 1;
			
			//mine
			if(map[i][j].mine == 1)
			{
				//map[i][j].flag =1;
				
				//all mines is displayed
				sweeper();
				
				//game is over and reset
				JOptionPane.showMessageDialog(null,"You are die!!" );
				initial();
			}
			
			//none mine
			else 
				clear(i,j);
			}
	}//end method lbutton
	
	//mouse handler to deal with the mouse event
	class Buttonhandler extends MouseAdapter 
	{
		
		public void mouseClicked (MouseEvent event)
		{
			//to check which mouse event
			for(int i=0;i<10;i++)
			{
				for(int j=0;j<10;j++)
				{
					//if the event is the button event,then......
					if(event.getSource() == buttons[i][j])
					{
						//right button is clicked
						if(event.isMetaDown())
						{
							if(buttons[i][j].Lclick == 0)
								rbutton(i,j);
						}
						//left button is clicked
						else
							lbutton(i,j);
					}
			   }// end iner for 
		   } // end outer for		
		} // end class Buttonhandler
	}
}   //end class Mine

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
xfplay精品久久| 亚洲自拍偷拍综合| 成人国产精品免费观看| 日韩理论片一区二区| 91麻豆自制传媒国产之光| 亚洲欧美日韩国产综合| 欧美日韩国产综合久久| 国产91在线观看| 性做久久久久久| 国产婷婷色一区二区三区| 播五月开心婷婷综合| 免费在线一区观看| 亚洲婷婷国产精品电影人久久| 欧美午夜免费电影| 国产成人丝袜美腿| 美国毛片一区二区| 一区二区在线观看视频| 欧美成人伊人久久综合网| 欧美中文字幕久久| 成人av在线电影| 国产jizzjizz一区二区| 毛片av一区二区三区| 午夜不卡在线视频| 国产精品久久久久aaaa| 精品久久久网站| 欧美一区二区在线免费观看| 在线视频你懂得一区| 97成人超碰视| 99久久精品免费看国产免费软件| 久久99国产精品免费网站| 亚洲va韩国va欧美va| 亚洲第一久久影院| 亚洲国产精品久久不卡毛片| 亚洲一区二区三区四区在线观看 | 精品久久久久久久久久久久久久久| 久久er99热精品一区二区| 免费成人在线影院| 国产精品一区二区在线观看不卡| 国内精品久久久久影院色| 成人av网站免费| 91福利在线免费观看| 欧美精品日韩精品| 国产精品日日摸夜夜摸av| 亚洲午夜精品17c| 国内精品嫩模私拍在线| 91网站黄www| 欧美成va人片在线观看| 亚洲老妇xxxxxx| 国产精品一区专区| 欧美日韩国产免费一区二区| 2014亚洲片线观看视频免费| 三级久久三级久久久| 成人黄色在线视频| 国产乱淫av一区二区三区 | 欧美日韩国产a| 免费看日韩精品| 亚洲在线一区二区三区| 亚洲人成7777| 天堂影院一区二区| 激情久久久久久久久久久久久久久久| 热久久国产精品| 成人一区二区三区视频在线观看| 99re视频这里只有精品| 91精品免费观看| 国产精品电影一区二区三区| 亚洲亚洲人成综合网络| 国内不卡的二区三区中文字幕 | 欧美图区在线视频| 亚洲婷婷综合久久一本伊一区| 日本视频中文字幕一区二区三区| 国产成人av一区二区三区在线| 88在线观看91蜜桃国自产| 国产午夜精品久久久久久久| 日本午夜精品视频在线观看| 欧美性大战久久久| 亚洲欧美激情在线| 国产精品一区2区| 日韩午夜中文字幕| 另类专区欧美蜜桃臀第一页| 日韩亚洲欧美综合| 另类综合日韩欧美亚洲| 欧美一区二区三区视频在线| 免费在线观看一区| 国产色婷婷亚洲99精品小说| 丁香五精品蜜臀久久久久99网站 | 亚洲精品第一国产综合野| 国产成人av影院| 中文字幕久久午夜不卡| 粉嫩av亚洲一区二区图片| 日韩理论片在线| 欧美剧在线免费观看网站| 久久 天天综合| 国产日韩精品一区二区三区| 国产精品一区二区三区99| 亚洲视频香蕉人妖| 日韩欧美www| 欧美三级韩国三级日本三斤| 国产乱码精品一区二区三区五月婷 | 欧美日韩精品福利| 成人av电影在线观看| 蜜臀av性久久久久蜜臀aⅴ | 99久久99久久免费精品蜜臀| 肉色丝袜一区二区| 欧美激情一区二区在线| 91麻豆精品国产91久久久久久| 暴力调教一区二区三区| 蜜桃久久av一区| 日本成人在线不卡视频| 亚洲成人www| 日韩美女视频一区二区| 久久久一区二区三区| 在线观看av一区| 国产一区二区电影| 狠狠色丁香婷婷综合| 亚洲国产精品久久久男人的天堂| 国产精品久久久久aaaa| 久久久不卡网国产精品二区| 欧美丰满美乳xxx高潮www| 欧美日韩一区二区三区免费看| 欧美三级三级三级爽爽爽| 欧美自拍偷拍午夜视频| 欧美一级高清片| 久久男人中文字幕资源站| 久久免费视频一区| 中文字幕欧美区| 国产精品三级电影| 国产精品久久777777| 伊人色综合久久天天人手人婷| 综合色中文字幕| 亚洲久本草在线中文字幕| 一区二区三区电影在线播| 一区二区三区欧美激情| 日韩电影在线一区二区三区| 久久99热狠狠色一区二区| www.66久久| 欧美大片在线观看| 国产精品国模大尺度视频| 亚洲一二三专区| 美女视频免费一区| 成人av在线播放网站| 欧美日韩一区二区在线视频| 精品国内二区三区| 五月婷婷激情综合| 91啪九色porn原创视频在线观看| 欧美日韩亚州综合| 亚洲啪啪综合av一区二区三区| 久久国产精品一区二区| 在线这里只有精品| 欧美韩日一区二区三区四区| 亚洲成人自拍网| 91网页版在线| 久久久精品tv| 国产一区二区主播在线| 久久久综合视频| 国产在线乱码一区二区三区| 欧美一区二区大片| 日本亚洲天堂网| 欧美视频在线观看一区| 一区二区三区精品视频| 日本亚洲一区二区| 国产一区二区伦理片| 欧美精品123区| 五月婷婷久久综合| 欧美一区二区三区四区在线观看| 日韩中文欧美在线| 日韩精品一区国产麻豆| 精品一区二区三区久久久| 久久综合久久综合久久综合| 国产激情91久久精品导航| 国产女人18水真多18精品一级做| 国产suv一区二区三区88区| 国产免费成人在线视频| 国产91精品一区二区| 亚洲柠檬福利资源导航| 成人免费高清在线| 日韩精品国产精品| 久久久精品免费网站| 91日韩一区二区三区| 丝瓜av网站精品一区二区| 欧美成人a∨高清免费观看| 国产成人啪免费观看软件| 亚洲午夜羞羞片| 久久久国产精华| 91福利国产成人精品照片| 久久99精品久久久久久动态图 | 懂色av一区二区三区免费看| 亚洲午夜久久久久| 国产女主播一区| 6080国产精品一区二区| 成人福利电影精品一区二区在线观看| 亚洲一二三四区| 亚洲视频一二区| 国产精品麻豆网站| 亚洲国产精品精华液ab| 精品国产乱码91久久久久久网站| 95精品视频在线| 99久久亚洲一区二区三区青草| 狂野欧美性猛交blacked| 亚洲不卡一区二区三区| 亚洲图片欧美色图|