java五子棋胜负判定_五子棋java程序的判断胜负的方法

我有这样一段程序:importjava.awt.*;importjava.awt.event.*;importjava.util.*;classFiveChessextendsCanvas{LinkedListblacklist=newLinkedList();LinkedListblacklist1=newLinked...

我有这样一段程序:

import java.awt.*;

import java.awt.event.*;

import java.util.*;

class FiveChess extends Canvas

{

LinkedList blacklist = new LinkedList();

LinkedList blacklist1 = new LinkedList();

int count1=0;

int c,c1,r1;

void init(){

this.winner();

this.addListener();

this.setSize(500,500);

this.setBackground(Color.yellow);

}

public void paint(Graphics g){

for(int x=0;x<=500;x=x+20){

g.drawLine(x,0,x,500);

}

for(int y=0;y<=500;y=y+20){

g.drawLine(0,y,500,y);

}

for (int i = 0;i < blacklist.size() ; i++)

{

if(i%2 ==0){

g.setColor(Color.black);

}

else{

g.setColor(Color.white);

}

Block b = (Block)blacklist.get(i);

g.fillOval(b.x,b.y,20,20);

}

}

void addListener(){

this.addMouseListener(new MouseAdapter(){

public void mouseClicked(MouseEvent e){

count1++;

int x = e.getX();

if((x/10)%2 == 0){

x = (x/10)*10 -10;

}

else{

x = (x/10)*10;

}

c1=x/10;

int y = e.getY();

if((y/10)%2 == 0){

y = (y/10)*10 - 10;

}

else{

y = (y/10)*10;

}

r1=y/10;

Block b = new Block(x,y);

blacklist.add(b);

repaint();

}

});

}

void winner(){

}

public static void main(String[] a){

Frame f=new Frame();

FiveChess ca=new FiveChess();

f.add(ca);

f.setBackground(Color.gray);

f.setLayout(new FlowLayout());

f.setSize(600,600);

f.setVisible(true);

ca.init();

}

}

可以运行处结果,但中间判断胜负的方法没写,请高手指教

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值