用eclipse编写一个基于java的五子棋(与电脑对弈) 100

需要用这个界面。求大神帮助。求eclipse工程文件打包发到邮箱:48047765。百度提醒我别人可以将文件可以上传到百度。所以发哪儿都可以。选修课的作业。。。求帮助!... 需要用这个界面。求大神帮助。求eclipse工程文件打包发到邮箱:48047765。百度提醒我别人可以将文件可以上传到百度。所以发哪儿都可以。
选修课的作业。。。求帮助!
展开
 我来答
育知同创教育
2016-03-08 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
展开全部

基于java的五子棋:

主要功能代码如下:

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Main extends JFrame implements ActionListener{
        private static final long serialVersionUID = 1L;
        JButton[][] point=new JButton[40][40];
        int[][] state=new int[40][40];
        int[][] value=new int[40][40];
        int[] place=new int[2];
        public Main(){
                this.setTitle("五子棋");
                this.setBounds(100,10,1000,1000);
                this.setLayout(new GridLayout(30,30));
                int i,j;
                for(i=0;i<=39;i++){
                        for(j=0;j<=39;j++){
                                state[i][j]=0;
                                value[i][j]=0;
                        }
                }
                for(i=5;i<=34;i++){
                        for (j=5;j<=34;j++){
                                point[i][j]=new JButton("");
                                this.add(point[i][j]);
                                point[i][j].addActionListener(this);
                        }
                }
                this.setVisible(true);
        }
        public void actionPerformed(ActionEvent e)
    {
            int i,j;
            for(i=5;i<=34;i++){
                    for(j=5;j<=34;j++){
                            if(e.getSource()==point[i][j]){
                                    point[i][j].setBackground(Color.RED);
                                    state[i][j]=1;
                                    point[i][j].setEnabled(false);
                                    value[i][j]=0;
                            }
                    }
            }
          
    public static void main(String[] args)throws NullPointerException{
            new Main();
    }

                else if(((state[i][j]==0)&&(state[i][j+1]==1)&&(state[i][j+2]==0))||
                                ((state[i][j]==0)&&(state[i][j-1]==1)&&(state[i][j-2]==0))||
                                ((state[i][j]==0)&&(state[i+1][j]==1)&&(state[i+2][j]==0))||
                                ((state[i][j]==0)&&(state[i-1][j]==1)&&(state[i-2][j]==0))||                               //空红空
                                ((state[i][j]==0)&&(state[i+1][j+1]==1)&&(state[i+2][j+2]==0))||
                                ((state[i][j]==0)&&(state[i+1][j-1]==1)&&(state[i+2][j-2]==0))||
                                ((state[i][j]==0)&&(state[i-1][j+1]==1)&&(state[i-2][j+2]==0))||
                                ((state[i][j]==0)&&(state[i-1][j-1]==1)&&(state[i-2][j-2]==0))||
                        ((state[i][j]==0)&&(state[i][j+1]==1)&&(state[i][j+2]==1)&&(state[i][j+3]==2))||
                                ((state[i][j]==0)&&(state[i][j-1]==1)&&(state[i][j-2]==1)&&(state[i][j-3]==2))||
                                ((state[i][j]==0)&&(state[i+1][j]==1)&&(state[i+2][j]==1)&&(state[i+3][j]==2))||
                                ((state[i][j]==0)&&(state[i-1][j]==1)&&(state[i-2][j]==1)&&(state[i-3][j]==2))||                            //空红红蓝型
                                ((state[i][j]==0)&&(state[i+1][j+1]==1)&&(state[i+2][j+2]==1)&&(state[i+3][j+3]==2))||
                                ((state[i][j]==0)&&(state[i+1][j-1]==1)&&(state[i+2][j-2]==1)&&(state[i+3][j-3]==2))||
                                ((state[i][j]==0)&&(state[i-1][j+1]==1)&&(state[i-2][j+2]==1)&&(state[i-3][j+3]==2))||
                                ((state[i][j]==0)&&(state[i-1][j-1]==1)&&(state[i-2][j-2]==1)&&(state[i-3][j-3]==2))){
                                value[i][j]=2;
                                return value[i][j];
                }
                else if(((state[i][j]==0)&&(state[i][j+1]==2)&&(state[i][j+2]==0))||
                                ((state[i][j]==0)&&(state[i][j-1]==2)&&(state[i][j-2]==0))||
                                ((state[i][j]==0)&&(state[i+1][j]==2)&&(state[i+2][j]==0))||
                                ((state[i][j]==0)&&(state[i-1][j]==2)&&(state[i-2][j]==0))||
                                ((state[i][j]==0)&&(state[i+1][j+1]==2)&&(state[i+2][j+2]==0))||
                                ((state[i][j]==0)&&(state[i+1][j-1]==2)&&(state[i+2][j-2]==0))||
                                ((state[i][j]==0)&&(state[i-1][j+1]==2)&&(state[i-2][j+2]==0))||
                                ((state[i][j]==0)&&(state[i-1][j-1]==2)&&(state[i-2][j-2]==0))||
                        ((state[i][j]==0)&&(state[i][j+1]==2)&&(state[i][j+2]==2)&&(state[i][j+3]==1))||
                                ((state[i][j]==0)&&(state[i][j-1]==2)&&(state[i][j-2]==2)&&(state[i][j-3]==1))||
                                ((state[i][j]==0)&&(state[i+1][j]==2)&&(state[i+2][j]==2)&&(state[i+3][j]==1))||
                                ((state[i][j]==0)&&(state[i-1][j]==2)&&(state[i-2][j]==2)&&(state[i-3][j]==1))||
                                ((state[i][j]==0)&&(state[i+1][j+1]==2)&&(state[i+2][j+2]==2)&&(state[i+3][j+3]==1))||
                                ((state[i][j]==0)&&(state[i+1][j-1]==2)&&(state[i+2][j-2]==2)&&(state[i+3][j-3]==1))||
                                ((state[i][j]==0)&&(state[i-1][j+1]==2)&&(state[i-2][j+2]==2)&&(state[i-3][j+3]==1))||
                                ((state[i][j]==0)&&(state[i-1][j-1]==2)&&(state[i-2][j-2]==2)&&(state[i-3][j-3]==1))){
                                value[i][j]=1;
                                return value[i][j];
                }
                else{
                        value[i][j]=0;
                        return value[i][j];
                }

    }
    public int[] largestValue(int[][] value){
            int max,i,j,l,k;
            l=0;k=0;
            max=0;
            for(i=5;i<34;i++){
                    for(j=5;j<34;j++){
                            if(max<value[i][j]){
                                    max=value[i][j];
                                    place[0]=i;
                                    place[1]=j;
                            }
                    }
            }
            return place;
    }
}

运行结果如下图所示:

找红太郎的灰灰
2014-11-20 · TA获得超过285个赞
知道小有建树答主
回答量:221
采纳率:0%
帮助的人:189万
展开全部
你这明显是个网页版的 你是要web的吗?
更多追问追答
追问
不是啊。需要用Java做界面出来
追答
已发送
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
那年的星期五
2014-11-20 · TA获得超过232个赞
知道小有建树答主
回答量:226
采纳率:50%
帮助的人:217万
展开全部
直接给你个链接吧,源码都在呢
http://blog.csdn.net/cnlht/article/details/8176130
经测试 可以用!有什么不知道的地方可以问我
追问
不好意思,我们对界面有要求啊。能不能帮忙做一个啊?
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 2条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式