下载此文档

Java五子棋源代码.docx


文档分类:IT计算机 | 页数:约10页 举报非法文档有奖
1/10
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/10 下载此文档
文档列表 文档介绍
本程序共有3个类,下载后将三个类复制到三个记事本里然后重名记事本(为了阅读方便分三个文件),其中main()方法在StartChessJFrame类中。
我是菜鸟,交流QQ:609429837
import ;
public class Point {
private int x;
//棋盘中X的索引
private int y;
//棋盘中Y的索引
private Color color;//颜色
public static final int DIAMETER = 30;
//直径
public Point(int x,int y,Color color){
=x;
=y;
=color;
}
//拿到棋盘中的Y索引
public int getX(){
return x;
}

public int getY(){
return y;
}

//得到颜色
public Color getColor(){
return color;
}
}
import .*;
import .*;
import ;
import ;
import ;
/*
五子棋-棋盘类
*/
public class ChessBoard extends JPanel implements MouseListener {
public static final int MARGIN = 30;
//边距
protected static final int GRID_SPAN = 35;
//网格间距
public static final int ROWS = 10;
//棋盘行数
public static final int COLS = 10;

//棋盘列数
Point[] chessList = new Point[(ROWS+1)*(COLS+1)];
//初始化每个数组元素为null
boolean isBlack = true;
//默认开始是黑棋先下
boolean gameOver = false;
//游戏是否结束
int chessCount;
//当前棋盘棋子的个数
int xIndex,yIndex;
//当前刚下的棋子的索引
public ChessBoard(){
();
//setBackground();//设置背景颜色为橘黄色
addMouseListener(this);//添加监听器
addMouseMotionListener(new MouseMotionListener(){//匿名内部类
public void mouseDragg

Java五子棋源代码 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数10
  • 收藏数0 收藏
  • 顶次数0
  • 上传人cdsqbyl
  • 文件大小0 KB
  • 时间2015-05-24
最近更新