java黑白棋游戏源代码 java黑白棋盘( 八 )


for (int n = 1; ni; n++) {
qi[x][y + n] = -1;
}
a = true;
if (qi[x][y + i] == 0)
i = 9;
}
}
}
if (x + 18qi[x + 1][y] == 1) {
for (int i = 2; x + i8; i++) {
if (qi[x + i][y] == -1) {
for (int n = 1; ni; n++) {
qi[x + n][y] = -1;
}
a = true;
if (qi[x + i][y] == 0)
i = 9;
}
}
}
if (x - 1 = 0qi[x - 1][y] == 1) {
for (int i = 2; x - i = 0; i++) {
if (qi[x - i][y] == -1) {
for (int n = 1; ni; n++) {
qi[x - n][y] = -1;
}
a = true;
if (qi[x - i][y] == 0)
i = 9;
}
}
}
if (x - 1 = 0y - 1 = 0qi[x - 1][y - 1] == 1) {
for (int i = 2; x - i = 0y - i = 0; i++) {
if (qi[x - i][y - i] == -1) {
for (int n = 1; ni; n++) {
qi[x - n][y - n] = -1;
}
a = true;
if (qi[x - i][y - i] == 0)
i = 9;
}
}
}
if (x + 18y - 1 = 0qi[x + 1][y - 1] == 1) {
for (int i = 2; x + i8y - i = 0; i++) {
if (qi[x + i][y - i] == -1) {
for (int n = 1; ni; n++) {
qi[x + n][y - n] = -1;
}
a = true;
if (qi[x + i][y - i] == 0)
i = 9;
}
}
}
if (x - 1 = 0y + 18qi[x - 1][y + 1] == 1) {
for (int i = 2; x - i = 0y + i8; i++) {
if (qi[x - i][y + i] == -1) {
for (int n = 1; ni; n++) {
qi[x - n][y + n] = -1;
}
a = true;
if (qi[x - i][y + i] == 0)
i = 9;
}
}
}
if (x + 18y + 18qi[x + 1][y + 1] == 1) {
for (int i = 2; x + i8y + i8; i++) {
if (qi[x + i][y + i] == -1) {
for (int n = 1; ni; n++) {
qi[x + n][y + n] = -1;
}
a = true;
if (qi[x + i][y + i] == 0)
i = 9;
}
}
}
}
}
if (a)
return true;
else
return false;
}
急求Java黑白棋设计源代码importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
importjava.awt.geom.*;
importjavax.swing.JOptionPane.*;
publicclassFiveChess
{
publicstaticvoidmain(String[]args)
{
JFramemyFrame=newJFrame("快乐五子棋");
myFrame.getContentPane().add(newMyPanel());
Toolkitmykit=myFrame.getToolkit();
Dimensionmysize=mykit.getScreenSize();
myFrame.setBounds(0,0,mysize.width,mysize.height-40);
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myFrame.show();
}
}
classMyPanelextendsJPanelimplementsMouseListener
{
privatePointstart=newPoint(0,0);
privatePointnext=newPoint(0,0);
boolean[][]chessBo=newboolean[19][19];
booleanchessCo=true; //判断颜色的 , true黑
booleanwinchess=true; //true,为胜利
MyPanel(){
addMouseListener(this);
setBackground(Color.blue);
}
publicbooleanwinkill(intx,inty) //win?
{
intcountBlack=0,countWhite=0;
booleanwinchess01=false;
//x,y取到r01,r02的值
for(inti=0;i5;i++)//判断纵向下
{
if((x+i)20)
break;
if(chessCochessBo[x+i][y])
countBlack++;
elseif(chessBo[x+i][y](chessCo==false))
countWhite++;
}
for(inti=0;i5;i++)//判断纵向上
{
if((x-i)=0)
break;
if(chessCochessBo[x-i][y])
countBlack++;
elseif(chessBo[x-i][y](chessCo==false))
countWhite++;
}
if((countBlack==5)||(countWhite==5))
winchess01=true;
returnwinchess01;
}
publicvoidpaint(Graphicsg)//画棋盘
{
Graphics2Dg2D=(Graphics2D)g;
g2D.setPaint(Color.black);
floatpay=60.0f,pbx=60.0f;
floatlett=25.0f;
Point2D.Floatp1=newPoint2D.Float(60.0f,pay);
Point2D.Floatp2=newPoint2D.Float(510.0f,pay);
Point2D.Floatp3=newPoint2D.Float(pbx,60.0f);
Point2D.Floatp4=newPoint2D.Float(pbx,510.0f);

推荐阅读