包含java300級源代碼的詞條

java 源代碼 基礎(chǔ)點的 謝謝

package com.regex;

讓客戶滿意是我們工作的目標,不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價值的長期合作伙伴,公司提供的服務(wù)項目有:主機域名、虛擬空間、營銷軟件、網(wǎng)站建設(shè)、大通網(wǎng)站維護、網(wǎng)站推廣。

import java.io.*;

import java.net.URLDecoder;

import java.util.regex.*;

public class Regex {

private int REMARK=0;

private int LOGIC=0;

private int PHYSIC=0;

boolean start=false;

/**

* @param args

*/

public static void main(String[] args) { //測試方法

// TODO Auto-generated method stub

Regex re=new Regex();

re.regCount("Regex.java");

System.out.println("remark Line: "+re.REMARK);

System.out.println("logic Line: "+re.LOGIC);

System.out.println("physic Line: "+re.PHYSIC);

}/**

* @author BlueDance

* @param s

* @deprecated count

*/

public void regCount(String s){

String url=null;

try {

url=URLDecoder.decode(this.getClass().getResource(s).getPath(),"UTF-8");

} catch (Exception e) {

e.printStackTrace();

// TODO: handle exception

}

try {

BufferedReader br=new BufferedReader(new FileReader(new File(url)));

String s1=null;

while((s1=br.readLine())!=null){

PHYSIC++;

if(CheckChar(s1)==1){

REMARK++;

System.out.println("純注釋行:"+s1);

}

if(CheckChar(s1)==2){

LOGIC++;

REMARK++;

System.out.println("非純注釋行:"+s1);

}

if(CheckChar(s1)==3)

LOGIC++;

}

} catch (FileNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}catch(IOException e){

e.printStackTrace();

}

}

/**

*

* @param s

* @return int

* @version check s

*/

public int CheckChar(String s){

String s1=null;

if(s!=null)

s1=s.trim();

//System.out.println(regCheck(s1,re));

if(regCheck(s1,"(//.*)")) //判斷//開頭的為純注釋行

return 1;

if(regCheck(s1,"(.*[;{})] *//.*)")) //判斷不是//開頭的非純注釋行

return 2;

if(regCheck(s1,"(//*.*)")){ //判斷/*開頭的純注釋行

start=true;

return 1;

}

if(regCheck(s1,"(.*[;{})]//*.*)")){ //判斷不是/*開頭的非純注釋行

start=true;

return 2;

}

if(regCheck(s1,"(.* */*/)")){ //判斷*/結(jié)尾的純注釋行

start=false;

return 1;

}

if(regCheck(s1,"(.* */*/.*)")!strCheck(s1)){ //判斷不是*/結(jié)尾的非純注釋行

if(strCheck(s1)){

start=false;

return 2;

}

}

if(start==true) //狀態(tài)代碼,start即/*開始時start=true*/結(jié)束時為false

return 1;

return 3;//ssssllll

}//aeee

/**

*

* @param s

* @param re

* @return boolean

*/

public boolean regCheck(String s,String re){ //正則表達試判斷方法

return Pattern.matches(re,s);

}

public boolean strCheck(String s){ //中間有*/的字符判斷 此方法最關(guān)鍵

if(s.indexOf("*/")0){

int count=0;

String y[]=s.split("/*/");

boolean boo[]=new boolean[y.length];

for (int i = 0; i y.length-1; i++) {

char c[]=y[i].toCharArray();

for (int j = 0; j c.length; j++) {

if(c[j]=='\\'c[j+1]=='"'){

count++;

}

}

if(count%2==0){

if(countNumber("\"",y[i])%2!=0){

boo[i]=true;

}else{

boo[i]=false;

}

}else{

if(countNumber("\"",y[i])%2==0){

boo[i]=true;

}else{

boo[i]=false;

}

}

}

for(int i=0;iboo.length;i++){

if(!boo[i])

return false;

}

return true;

}

return false;

}

public int countNumber(String s,String y){ //此方法為我前面寫的字符串出現(xiàn)次數(shù)統(tǒng)計方法,不懂的可以看我前面的文章

int count=0;

String [] k=y.split(s);

if(y.lastIndexOf(s)==(y.length()-s.length()))

count=k.length;

else

count=k.length-1;

if(count==0)

System.out.println ("字符串\""+s+"\"在字符串\""+y+"\"沒有出現(xiàn)過");

else

return count;

return -1;

}

}

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class GoodLucky extends JFrame implements ActionListener{

JTextField tf = new JTextField(); //實例化一個文本域

//設(shè)置兩個按鈕

JButton b1 = new JButton("開始");

JButton b2 = new JButton("停止");

boolean isGo = false;

//構(gòu)造函數(shù)

public GoodLucky(){

b1.setActionCommand("start");//在開始按鈕上設(shè)置一個動作監(jiān)聽 start

JPanel p = new JPanel(); //實例化一個可視化容器

//將兩個按鈕添加到可視化容器上面,用add方法

p.add(b1);

p.add(b2);

//在兩個按鈕上增加監(jiān)聽的屬性,自動調(diào)用下面的監(jiān)聽處理方法actionPerformed(ActionEvent e),如果要代碼有更好的可讀性,可用內(nèi)部類實現(xiàn)動作

//監(jiān)聽處理。

b1.addActionListener(this);

b2.addActionListener(this);

//將停止按鈕設(shè)置為不可編輯(即不可按的狀態(tài))

b2.setEnabled(false);

this.getContentPane().add(tf,"North"); //將上面的文本域放在面板的北方,也就是上面(上北下南左西右東)

this.getContentPane().add(p,"South"); //將可視化容器pannel放在南邊,也就是下面

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //設(shè)置用戶在此窗體上發(fā)起 "close" 時默認執(zhí)行的操作,參數(shù)EXIT_ON_CLOSE是使用 System exit 方法退出應(yīng)用程序。僅在應(yīng)用程序中使用

this.setSize(300,200); //設(shè)置面板大小,寬和高

this.setLocation(300,300); //設(shè)置面板剛開始的出現(xiàn)的位置

Cursor cu = new Cursor(Cursor.HAND_CURSOR); //用指定名稱創(chuàng)建一個新的定制光標對象,參數(shù)表示手狀光標類型

this.setCursor(cu); //為指定的光標設(shè)置光標圖像,即設(shè)置光標圖像為上面所創(chuàng)建的手狀光標類型

this.setVisible(true); //將面板可視化設(shè)置為true,即可視,如果為false,即程序運行時面板會隱藏

tf.setText("welcome you! "); //設(shè)置面板的標題為歡迎

this.go(); //調(diào)用go方法

}

public void go(){

while(true){ //這里是死循環(huán),也就是說用戶不點擊停止按鈕的話他一直循環(huán)出現(xiàn)隨機數(shù),直到用戶點擊停止按鈕循環(huán)才能推出,具體流程在actionPerformed方法中控制。

if(isGo == true){ //上面所定義的isGo的初始值為false,所以程序第一次到此會跳過

String s = ""; //設(shè)置空字符串

for(int j = 1; j = 7;j++){ //產(chǎn)生7個隨機數(shù)

int i = (int)(Math.random() * 36) + 1;//每個隨機數(shù)產(chǎn)生方式,這里定義靈活,可以自由定義隨機數(shù)產(chǎn)生的方式

if(i 10){

s = s + " 0" + i; //如果產(chǎn)生的隨機數(shù)小于10的話做處理:這里就牽扯到一個重要的概念,簡單敘述一下:

/*

當(dāng)一個字符串與一個整型數(shù)項相加的意思是連接,上面的s = s + " 0" + i的意思是字符串s鏈接0再連接整型i值,而不會導(dǎo)致0和整型的i相加,

產(chǎn)生的效果為s0i,由于s為空字符串(上面定義過的),所以當(dāng)i小于零時,在個位數(shù)前面加上0,比如產(chǎn)生的隨機數(shù)i為7的話,顯示效果為 07.

*/

}else{

s = s + " " + i; //如果產(chǎn)生的隨機數(shù)比10打的話,那么加上空格顯示,即數(shù)字和數(shù)字之間有個空格

}

//以上循環(huán)循環(huán)七次,以保證能出現(xiàn)7個隨機數(shù)

}

tf.setText(s); //將產(chǎn)生的隨機數(shù)全部顯示在文本域上,用文本域?qū)ο髏f調(diào)用它的設(shè)置文本的方法setText(String)實現(xiàn)。

}

//以下為線程延遲

try{

Thread.sleep(10); //線程類同步方法sleep,睡眠方法,括號里的單位為ms。

}catch(java.lang.InterruptedException e){

e.printStackTrace(); //異常捕獲,不用多說。

}

}

}

//以下是上面設(shè)置的事件監(jiān)聽的具體處理辦法,即監(jiān)聽時間處理方法,自動調(diào)用

public void actionPerformed(ActionEvent e){ //傳入一個動作事件的參數(shù)e

String s = e.getActionCommand(); //設(shè)置字符串s來存儲獲得動作監(jiān)聽,上面的start

/*

以下這個條件語句塊的作用為:用戶點擊開始后(捕獲start,用方法getActionCommand()),將命令觸發(fā)設(shè)置為true,從而執(zhí)行上面的go方法中的循環(huán)體(因為循環(huán)體中要求isGo參數(shù)為true,而初始為false)。

執(zhí)行循環(huán)快產(chǎn)生隨機數(shù),并將開始按鈕不可編輯化,而用戶只可以使用停止按鈕去停止。如果用戶按下停止時,也就是沒有傳入?yún)?shù)“start”的時候,

執(zhí)行else語句塊中的語句,isGo設(shè)置為false,將不執(zhí)行上面go中的循環(huán)語句塊,從而停止產(chǎn)生隨機數(shù),并顯示,并且把開始按鈕設(shè)置為可用,而把

停止按鈕設(shè)置為不可用,等待用戶按下開始再去開始新一輪循環(huán)產(chǎn)生隨機數(shù)。

*/

if(s.equals("start")){ //如果捕獲到start,也就是用戶觸發(fā)了動作監(jiān)聽器,那么下面處理

isGo = true; //設(shè)置isGo為true

b1.setEnabled(false); //將開始按鈕設(shè)置為不可用

b2.setEnabled(true); //將停止按鈕設(shè)置為可用

}else{

isGo = false; //將isGo設(shè)置為false,isGo為循環(huán)標志位

b2.setEnabled(false); //設(shè)置停止按鈕為不可用(注意看是b2,b2是停止按鈕)

b1.setEnabled(true); //設(shè)置開始按鈕為可用

}

}

public static void main(String[] args){

new GoodLucky(); //產(chǎn)生類的實例,執(zhí)行方法

}

}

急求大神發(fā)幾個java 300行代碼的小程序 簡單點的

/**

* 文件名:Operation.java 2014-1-2 下午3:06:37

* @author Administrator

*/

package cc.icoc.javaxu.action;

import java.util.ArrayList;

import java.util.Scanner;

import cc.icoc.javaxu.datas.StudentInfo;

/**

* @author 許仕永

* 創(chuàng)建時間: 2014 2014-1-2 下午3:06:37

*/

public class Operation

{

int stuNo,stuAge;

String stuName,stuClass,stuSex;

ArrayListStudentInfo list;

/**程序入口

* @param args

*/

public static void main(String[] args)

{

// TODO Auto-generated method stub

new Operation().operation();

}

private int inputInt()

{

Scanner scanner = new Scanner(System.in);

return scanner.nextInt();

}

private String inputStr()

{

Scanner scanner = new Scanner(System.in);

return scanner.nextLine();

}

private void operation()

{

// TODO Auto-generated method stub

if(list == null)

{

list = new ArrayListStudentInfo();

}

while(true)

{

System.out.println("\t\t\t學(xué)生信息管理系統(tǒng)\n");

System.out.println("1.信息查閱");

System.out.println("2.信息查詢");

System.out.println("3.信息錄入");

System.out.println("4.退出系統(tǒng)");

int what = inputInt();

if ( what == 1 )

{

getInfo();

} else if ( what == 2 )

{

allSerach();

} else if ( what == 3 )

{

inputInfo();

} else if( what == 4 )

{

System.out.println("已經(jīng)退出系統(tǒng)");

System.exit(0);

}

}

}

/**

* 獲取全部學(xué)生的信息列表

*/

private void getInfo()

{

if(!list.isEmpty())

{

for ( int i = 0; i list.size(); i++ )

{

System.out.println(list.get(i));

}

}

}

/**

* 執(zhí)行查找

*/

private void allSerach()

{

System.out.println("1.輸入學(xué)號進行查詢");

System.out.println("2.輸入姓名進行查詢");

int what = inputInt();

if(what == 1)

{

System.out.println("請輸入學(xué)號:");

search(inputInt());

}

else

{

System.out.println("請輸入姓名:");

search(inputStr());

}

}

/**

* 按學(xué)生姓名查詢學(xué)生信息

* @param name 學(xué)生姓名

*/

private StudentInfo search(String name)

{

for ( int i = 0; i list.size(); i++ )

{

if(list.get(i).getStuName().equals(name))

{

System.out.println(list.get(i));

return list.get(i);

}

}

System.out.println("未查詢到該名字的學(xué)生");

return null;

}

/**

* 按學(xué)號查詢學(xué)生信息

* @param id 學(xué)號

*/

private StudentInfo search(int id)

{

for ( int i = 0; i list.size(); i++ )

{

if(list.get(i).getStuNo()==id)

{

System.out.println(list.get(i));

return list.get(i);

}

}

System.out.println("未查詢到該學(xué)號的學(xué)生");

return null;

}

/**

* 錄入學(xué)生信息

*/

private void inputInfo()

{

try

{

System.out.print("請輸入學(xué)生學(xué)號:\n");

stuNo = inputInt();

System.out.print("請輸入學(xué)生姓名:\n");

stuName = inputStr();

System.out.print("請輸入學(xué)生性別:\n");

stuSex = inputStr();

System.out.print("請輸入學(xué)生年齡:\n");

stuAge = inputInt();

System.out.print("請輸入學(xué)生班級:\n");

stuClass = inputStr();

list.add(new StudentInfo(stuNo, stuAge, stuName, stuSex, stuClass));

} catch (Exception e)

{

// TODO: handle exception

System.out.println("不允許為空,請重新輸入");

}

}

}

package cc.icoc.javaxu.action;

import java.util.ArrayList;

import java.util.List;

import java.util.Scanner;

public class Stu

{

int countStu = 0;

int sum = 0;

int avg = 0;

ListStuBean list = new ArrayListStu.StuBean();

public static void main(String[] args)

{

new Stu().go();

}

private void go()

{

A:while(true)

{

//構(gòu)造實體Bean來存儲學(xué)生成績

StuBean bean = new StuBean();

System.out.println("請輸入成績:");

System.out.println("語文:");

bean.setYuwen(scanner());

System.out.println("數(shù)學(xué):");

bean.setMath(scanner());

//獲取英語成績

System.out.println("英語:");

bean.setEnglish(scanner());

//存入容器

list.add(bean);

for ( int i = 0; i list.size(); i++ )

{

sum += list.get(i).english+list.get(i).math+list.get(i).yuwen;

}

avg = sum / (3*list.size());

System.out.println("當(dāng)前有"+list.size()+"條學(xué)生記錄,所有學(xué)生總分="+sum+"平均分為"+avg);

//輸入y繼續(xù)錄入學(xué)生信息,輸入x退出

System.out.println("\n已成功錄入一個學(xué)生的數(shù)據(jù),是否繼續(xù)/退出(y/x)");

if("x".equals(scannerString()))

break A;

}

}

/**輸入*/

private int scanner()

{

Scanner scanner = new Scanner(System.in);

return scanner.nextInt();

}

/**輸入*/

private String scannerString()

{

Scanner scanner = new Scanner(System.in);

return scanner.nextLine();

}

class StuBean

{

int math;

int yuwen;

int english;

public int getMath()

{

return math;

}

public void setMath(int math)

{

this.math = math;

}

public int getYuwen()

{

return yuwen;

}

public void setYuwen(int yuwen)

{

this.yuwen = yuwen;

}

public int getEnglish()

{

return english;

}

public void setEnglish(int english)

{

this.english = english;

}

}

}

/**

* 文件名:StudentInfo.java 2014-1-2 下午3:07:29

* @author Administrator

*/

package cc.icoc.javaxu.datas;

/**

* @author 許仕永

* 創(chuàng)建時間: 2014 2014-1-2 下午3:07:29

*/

public class StudentInfo

{

int stuNo,stuAge;

String stuName,stuSex,stuClass;

public StudentInfo(int stuNo, int stuAge, String stuName, String stuSex, String stuClass)

{

super();

this.stuNo = stuNo;

this.stuAge = stuAge;

this.stuName = stuName;

this.stuSex = stuSex;

this.stuClass = stuClass;

}

public int getStuNo()

{

return stuNo;

}

public void setStuNo(int stuNo)

{

this.stuNo = stuNo;

}

public int getStuAge()

{

return stuAge;

}

public void setStuAge(int stuAge)

{

this.stuAge = stuAge;

}

public String getStuName()

{

return stuName;

}

public void setStuName(String stuName)

{

this.stuName = stuName;

}

public String getStuSex()

{

return stuSex;

}

public void setStuSex(String stuSex)

{

this.stuSex = stuSex;

}

public String getStuClass()

{

return stuClass;

}

public void setStuClass(String stuClass)

{

this.stuClass = stuClass;

}

@Override

public String toString()

{

// TODO Auto-generated method stub

String s = "學(xué)號:"+getStuNo()+"\t姓名:"+getStuName()+" \t性別:"+getStuSex()+"\t年齡:"+getStuAge()+"\t班級:"+getStuClass();

return s;

}

}

JAVA代碼

連連看java源代碼

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class lianliankan implements ActionListener

{

JFrame mainFrame; //主面板

Container thisContainer;

JPanel centerPanel,southPanel,northPanel; //子面板

JButton diamondsButton[][] = new JButton[6][5];//游戲按鈕數(shù)組

JButton exitButton,resetButton,newlyButton; //退出,重列,重新開始按鈕

JLabel fractionLable=new JLabel("0"); //分數(shù)標簽

JButton firstButton,secondButton; //分別記錄兩次被選中的按鈕

int grid[][] = new int[8][7];//儲存游戲按鈕位置

static boolean pressInformation=false; //判斷是否有按鈕被選中

int x0=0,y0=0,x=0,y=0,fristMsg=0,secondMsg=0,validateLV; //游戲按鈕的位置坐標

int i,j,k,n;//消除方法控制

public void init(){

mainFrame=new JFrame("JKJ連連看");

thisContainer = mainFrame.getContentPane();

thisContainer.setLayout(new BorderLayout());

centerPanel=new JPanel();

southPanel=new JPanel();

northPanel=new JPanel();

thisContainer.add(centerPanel,"Center");

thisContainer.add(southPanel,"South");

thisContainer.add(northPanel,"North");

centerPanel.setLayout(new GridLayout(6,5));

for(int cols = 0;cols 6;cols++){

for(int rows = 0;rows 5;rows++ ){

diamondsButton[cols][rows]=new JButton(String.valueOf(grid[cols+1][rows+1]));

diamondsButton[cols][rows].addActionListener(this);

centerPanel.add(diamondsButton[cols][rows]);

}

}

exitButton=new JButton("退出");

exitButton.addActionListener(this);

resetButton=new JButton("重列");

resetButton.addActionListener(this);

newlyButton=new JButton("再來一局");

newlyButton.addActionListener(this);

southPanel.add(exitButton);

southPanel.add(resetButton);

southPanel.add(newlyButton);

fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText())));

northPanel.add(fractionLable);

mainFrame.setBounds(280,100,500,450);

mainFrame.setVisible(true);

}

public void randomBuild() {

int randoms,cols,rows;

for(int twins=1;twins=15;twins++) {

randoms=(int)(Math.random()*25+1);

for(int alike=1;alike=2;alike++) {

cols=(int)(Math.random()*6+1);

rows=(int)(Math.random()*5+1);

while(grid[cols][rows]!=0) {

cols=(int)(Math.random()*6+1);

rows=(int)(Math.random()*5+1);

}

this.grid[cols][rows]=randoms;

}

}

}

public void fraction(){

fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText())+100));

}

public void reload() {

int save[] = new int[30];

int n=0,cols,rows;

int grid[][]= new int[8][7];

for(int i=0;i=6;i++) {

for(int j=0;j=5;j++) {

if(this.grid[i][j]!=0) {

save[n]=this.grid[i][j];

n++;

}

}

}

n=n-1;

this.grid=grid;

while(n=0) {

cols=(int)(Math.random()*6+1);

rows=(int)(Math.random()*5+1);

while(grid[cols][rows]!=0) {

cols=(int)(Math.random()*6+1);

rows=(int)(Math.random()*5+1);

}

this.grid[cols][rows]=save[n];

n--;

}

mainFrame.setVisible(false);

pressInformation=false; //這里一定要將按鈕點擊信息歸為初始

init();

for(int i = 0;i 6;i++){

for(int j = 0;j 5;j++ ){

if(grid[i+1][j+1]==0)

diamondsButton[i][j].setVisible(false);

}

}

}

public void estimateEven(int placeX,int placeY,JButton bz) {

if(pressInformation==false) {

x=placeX;

y=placeY;

secondMsg=grid[x][y];

secondButton=bz;

pressInformation=true;

}

else {

x0=x;

y0=y;

fristMsg=secondMsg;

firstButton=secondButton;

x=placeX;

y=placeY;

secondMsg=grid[x][y];

secondButton=bz;

if(fristMsg==secondMsg secondButton!=firstButton){

xiao();

}

}

}

public void xiao() { //相同的情況下能不能消去。仔細分析,不一條條注釋

if((x0==x (y0==y+1||y0==y-1)) || ((x0==x+1||x0==x-1)(y0==y))){ //判斷是否相鄰

remove();

}

else{

for (j=0;j7;j++ ) {

if (grid[x0][j]==0){ //判斷第一個按鈕同行哪個按鈕為空

if (yj) { //如果第二個按鈕的Y坐標大于空按鈕的Y坐標說明第一按鈕在第二按鈕左邊

for (i=y-1;i=j;i-- ){ //判斷第二按鈕左側(cè)直到第一按鈕中間有沒有按鈕

if (grid[x][i]!=0) {

k=0;

break;

}

else //K=1說明通過了第一次驗證

}

if (k==1) {

linePassOne();

}

}

if (yj){ //如果第二個按鈕的Y坐標小于空按鈕的Y坐標說明第一按鈕在第二按鈕右邊

for (i=y+1;i=j ;i++ ){ //判斷第二按鈕左側(cè)直到第一按鈕中間有沒有按鈕

if (grid[x][i]!=0){

k=0;

break;

}

else

}

if (k==1){

linePassOne();

}

}

if (y==j ) {

linePassOne();

}

}

if (k==2) {

if (x0==x) {

remove();

}

if (x0x) {

for (n=x0;n=x-1;n++ ) {

if (grid[n][j]!=0) {

k=0;

break;

}

if(grid[n][j]==0 n==x-1) {

remove();

}

}

}

if (x0x) {

for (n=x0;n=x+1 ;n-- ) {

if (grid[n][j]!=0) {

k=0;

break;

}

if(grid[n][j]==0 n==x+1) {

remove();

}

}

}

}

}

for (i=0;i8;i++ ) { //列

if (grid[i][y0]==0) {

if (xi) {

for (j=x-1;j=i ;j-- ) {

if (grid[j][y]!=0) {

k=0;

break;

}

else

}

if (k==1) {

rowPassOne();

}

}

if (xi) {

for (j=x+1;j=i;j++ ) {

if (grid[j][y]!=0) {

k=0;

break;

}

else

}

if (k==1) {

rowPassOne();

}

}

if (x==i) {

rowPassOne();

}

}

if (k==2){

if (y0==y) {

remove();

}

if (y0y) {

for (n=y0;n=y-1 ;n++ ) {

if (grid[i][n]!=0) {

k=0;

break;

}

if(grid[i][n]==0 n==y-1) {

remove();

}

}

}

if (y0y) {

for (n=y0;n=y+1 ;n--) {

if (grid[i][n]!=0) {

k=0;

break;

}

if(grid[i][n]==0 n==y+1) {

remove();

}

}

}

}

}

}

}

public void linePassOne(){

if (y0j){ //第一按鈕同行空按鈕在左邊

for (i=y0-1;i=j ;i-- ){ //判斷第一按鈕同左側(cè)空按鈕之間有沒按鈕

if (grid[x0][i]!=0) {

k=0;

break;

}

else //K=2說明通過了第二次驗證

}

}

if (y0j){ //第一按鈕同行空按鈕在與第二按鈕之間

for (i=y0+1;i=j ;i++){

if (grid[x0][i]!=0) {

k=0;

break;

}

else

}

}

}

public void rowPassOne(){

if (x0i) {

for (j=x0-1;j=i ;j-- ) {

if (grid[j][y0]!=0) {

k=0;

break;

}

else

}

}

if (x0i) {

for (j=x0+1;j=i ;j++ ) {

if (grid[j][y0]!=0) {

k=0;

break;

}

else

}

}

}

public void remove(){

firstButton.setVisible(false);

secondButton.setVisible(false);

fraction();

pressInformation=false;

k=0;

grid[x0][y0]=0;

grid[x][y]=0;

}

public void actionPerformed(ActionEvent e) {

if(e.getSource()==newlyButton){

int grid[][] = new int[8][7];

this.grid = grid;

randomBuild();

mainFrame.setVisible(false);

pressInformation=false;

init();

}

if(e.getSource()==exitButton)

System.exit(0);

if(e.getSource()==resetButton)

reload();

for(int cols = 0;cols 6;cols++){

for(int rows = 0;rows 5;rows++ ){

if(e.getSource()==diamondsButton[cols][rows])

estimateEven(cols+1,rows+1,diamondsButton[cols][rows]);

}

}

}

public static void main(String[] args) {

lianliankan llk = new lianliankan();

llk.randomBuild();

llk.init();

}

}

//old 998 lines

//new 318 lines

分享文章:包含java300級源代碼的詞條
網(wǎng)站地址:http://muchs.cn/article14/doegcge.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供云服務(wù)器服務(wù)器托管、微信小程序、靜態(tài)網(wǎng)站、網(wǎng)站維護商城網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設(shè)