国产偷录视频叫床高潮,国产精品久久久久久影视,国产乱理伦片a级在线观看,国产精品无码a∨精品影院,国产片av国语在线观看

五子棋畫棋子的問題

importjava.awt.*;

importjava.awt.event.*;

importjava.applet.Applet;

importjava.awt.Color;

publicclassWuZhiqiextendsAppletimplementsActionListener,MouseListener,

MouseMotionListener,ItemListener{

intcolor=0;//旗子的顏色標(biāo)識(shí)0:白子1:黑子

booleanisStart=false;//游戲開始標(biāo)志

intbodyArray[][]=newint[16][16];//設(shè)置棋盤棋子狀態(tài)0無子1白子2黑子

Buttonb1=newButton(游戲開始);

Buttonb2=newButton(重置游戲);

LabellblWin=newLabel();

CheckboxckbHB[]=newCheckbox[2];

CheckboxGroupckgHB=newCheckboxGroup();

publicvoidinit(){

setLayout(null);

addMouseListener(this);

add(b1);

b1.setBounds(330,50,80,30);

b1.addActionListener(this);

add(b2);

b2.setBounds(330,90,80,30);

b2.addActionListener(this);

ckbHB[0]=newCheckbox(白子先,ckgHB,false);

ckbHB[0].setBounds(320,20,60,30);

ckbHB[1]=newCheckbox(黑子先,ckgHB,false);

ckbHB[1].setBounds(380,20,60,30);

add(ckbHB[0]);

add(ckbHB[1]);

ckbHB[0].addItemListener(this);

ckbHB[1].addItemListener(this);

add(lblWin);

lblWin.setBounds(330,130,80,30);

gameInit();

this.resize(newDimension(450,350));

}

publicvoiditemStateChanged(ItemEvente){

if(ckbHB[0].getState())//選擇黑子先還是白子先

{

color=0;

}else{

color=1;

}

}

publicvoidactionPerformed(ActionEvente){

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

gameStart();

}else{

reStart();

}

}

publicvoidmousePressed(MouseEvente){

}

publicvoidmouseClicked(MouseEvente){

intx1,y1;

x1=e.getX();

y1=e.getY();

if(e.getX()300||e.getY()300){

return;

}

if(x1%20>10){

x1+=20;

}

if(y1%20>10){

y1+=20;

}

x1=x1/20*20;

y1=y1/20*20;

setDown(x1,y1);

}

publicvoidmouseEntered(MouseEvente){

}

publicvoidmouseExited(MouseEvente){

}

publicvoidmouseReleased(MouseEvente){

}

publicvoidmouseDragged(MouseEvente){

}

publicvoidmouseMoved(MouseEvente){

}

publicvoidpaint(Graphicsg){

g.setColor(Color.lightGray);

g.fill3DRect(10,10,300,300,true);

g.setColor(Color.black);

for(inti=1;i<16;i++){

g.drawLine(20,20*i,300,20*i);

g.drawLine(20*i,20,20*i,300);

}

}

publicvoidsetDown(intx,inty)//落子

{

if(!isStart)//判斷游戲未開始

{

return;

}

if(bodyArray[x/20][y/20]!=0){

return;

}

Graphicsg=getGraphics();

if(color==1)//判斷黑子還是白子

{

g.setColor(Color.black);

color=0;

}else{

g.setColor(Color.white);

color=1;

}

g.fillOval(x-10,y-10,20,20);

bodyArray[x/20][y/20]=color+1;

if(gameWin1(x/20,y/20))//判斷輸贏

{

lblWin.setText(startColor(color)+贏了!);

isStart=false;

}

if(gameWin2(x/20,y/20))//判斷輸贏

{

lblWin.setText(startColor(color)+贏了!);

isStart=false;

}

if(gameWin3(x/20,y/20))//判斷輸贏

{

lblWin.setText(startColor(color)+贏了!);

isStart=false;

}

if(gameWin4(x/20,y/20))//判斷輸贏

{

lblWin.setText(startColor(color)+贏了!);

isStart=false;

}

}

publicStringstartColor(intx){

if(x==0){

return黑子;

}else{

return白子;

}

}

publicvoidgameStart()//游戲開始

{

isStart=true;

enableGame(false);

b2.setEnabled(true);

}

publicvoidgameInit()//游戲開始初始化

{

isStart=false;

enableGame(true);

b2.setEnabled(false);

ckbHB[0].setState(true);

for(inti=0;i<16;i++){

for(intj=0;j<16;j++){

bodyArray[i][j]=0;

}

}

lblWin.setText();

}

publicvoidreStart()//游戲重新開始

{

repaint();

gameInit();

}

publicvoidenableGame(booleane)//設(shè)置組件狀態(tài)

{

b1.setEnabled(e);

b2.setEnabled(e);

ckbHB[0].setEnabled(e);

ckbHB[1].setEnabled(e);

}

publicbooleangameWin1(intx,inty)//判斷輸贏橫

{

intx1,y1,t=1;

x1=x;

y1=y;

for(inti=1;i<5;i++){

if(x1>15){

break;

}

if(bodyArray[x1+i][y1]==bodyArray[x][y]){

t+=1;

}else{

break;

}

}

for(inti=1;i<5;i++){

if(x1<1){

break;

}

if(bodyArray[x1-i][y1]==bodyArray[x][y]){

t+=1;

}else{

break;

}

}

if(t>4){

returntrue;

}else{

returnfalse;

}

}

publicbooleangameWin2(intx,inty)//判斷輸贏豎

{

intx1,y1,t=1;

x1=x;

y1=y;

for(inti=1;i<5;i++){

if(x1>15){

break;

}

if(bodyArray[x1][y1+i]==bodyArray[x][y]){

t+=1;

}else{

break;

}

}

for(inti=1;i<5;i++){

if(x1<1){

break;

}

if(bodyArray[x1][y1-i]==bodyArray[x][y]){

t+=1;

}else{

break;

}

}

if(t>4){

returntrue;

}else{

returnfalse;

}

}

publicbooleangameWin3(intx,inty)//判斷輸贏左斜

{

intx1,y1,t=1;

x1=x;

y1=y;

for(inti=1;i<5;i++){

if(x1>15){

break;

}

if(bodyArray[x1+i][y1-i]==bodyArray[x][y]){

t+=1;

}else{

break;

}

}

for(inti=1;i<5;i++){

if(x1<1){

break;

}

if(bodyArray[x1-i][y1+i]==bodyArray[x][y]){

t+=1;

}else{

break;

}

}

if(t>4){

returntrue;

}else{

returnfalse;

}

}

publicbooleangameWin4(intx,inty)//判斷輸贏左斜

{

intx1,y1,t=1;

x1=x;

y1=y;

for(inti=1;i<5;i++){

if(x1>15){

break;

}

if(bodyArray[x1+i][y1+i]==bodyArray[x][y]){

t+=1;

}else{

break;

}

}

for(inti=1;i<5;i++){

if(x1<1){

break;

}

if(bodyArray[x1-i][y1-i]==bodyArray[x][y]){

t+=1;

}else{

break;

}

}

if(t>4){

returntrue;

}else{

returnfalse;

}

}

}

免責(zé)聲明:本站發(fā)布的游戲攻略(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng)。
如果本文侵犯了您的權(quán)益,請(qǐng)聯(lián)系站長(zhǎng)郵箱進(jìn)行舉報(bào)反饋,一經(jīng)查實(shí),我們將在第一時(shí)間處理,感謝您對(duì)本站的關(guān)注!