13格的五子棋代码

13格的五子棋代码

ID:18241430

大小:46.50 KB

页数:12页

时间:2018-09-15

13格的五子棋代码_第1页
13格的五子棋代码_第2页
13格的五子棋代码_第3页
13格的五子棋代码_第4页
13格的五子棋代码_第5页
资源描述:

《13格的五子棋代码》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、package作业;importjava.awt.BorderLayout;importjava.awt.Color;importjava.awt.Container;importjava.awt.FlowLayout;importjava.awt.Graphics;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.awt.event.MouseAdapter;importjava.awt.event.MouseEvent;importjavax.swing.JBut

2、ton;importjavax.swing.JFrame;importjavax.swing.JLabel;publicclasswuziqiextendsJFrame{intx=0,y=0;//初始化坐标的两个参数//初始化棋盘九个落棋位置intchequer[][];{chequer=newint[13][13];for(inti=0;i<13;i++)for(intj=0;j<13;j++)chequer[i][j]=0;}intlocation=0;//初始化坐标位置booleanstart=true,redplay=true,success=false;//初始化重

3、新开始,下棋,胜利//初始化棋盘九个落棋位置ints[]=newint[155],jj[]=newint[155];//初始化棋局位置,棋子信息JButtonjbutton1,jbutton2;//定义重新开始红队先下,重新开始蓝队先下两个按钮JLabeljlabel;//定义标签publicwuziqi(){Containerc=getContentPane();//给容器赋值istheTibetanPlateaupoly.Centercityonlyapopulationofoveronemillion.Xiningislocatedinthe"Tangfangudao"

4、andtheancient"SilkRoad"road,istheLoessPlateauandtheTibetanPlateau,agriculturalandpastoralareasand,inconjunctionwiththeMinistryofcultureandIslamicculture11c.setLayout(newFlowLayout());jbutton1=newJButton("重新开始红队先下");c.add(jbutton1);jbutton2=newJButton("重新开始蓝队先下");c.add(jbutton2);jlabel=newJL

5、abel();c.add(jlabel,BorderLayout.SOUTH);//增加鼠标监听器addMouseListener(newMouseAdapter(){publicvoidmousePressed(MouseEventevent){if(event.isAltDown()){repaint();}//获得鼠标点击的坐标x=event.getPoint().x;y=event.getPoint().y;System.out.println("坐标是:"+x+","+y+";");intlocation=location(x,y);//用a保存坐标的信息Syste

6、m.out.println("location="+location);//一方胜利或平局就重新开始if(success){jlabel.setForeground(Color.RED);jlabel.setText(""+"游戏已结束,请重新开始"+"");}//棋局还没结束,继续下棋istheTibetanPlateaupoly.Centercityonlyapopulationofoveronemillion.Xiningislocatedinthe"Tangfangudao"andtheancient"SilkRoad"road,istheLoessPlateauan

7、dtheTibetanPlateau,agriculturalandpastoralareasand,inconjunctionwiththeMinistryofcultureandIslamicculture11else{//如果先前一位置上已有一棋子,在此位置上再有一棋子就提醒另选位置重新下棋if(s[location]==1){jlabel.setForeground(Color.RED);jlabel.setText(""+"此位置有棋子,请另选位置重新下棋"+"");}//如果此位置是第一次有

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。