欢迎来到天天文库
浏览记录
ID:31920035
大小:122.00 KB
页数:33页
时间:2019-01-27
《java程序设计五子棋》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、.packageFiveChess;importjava.awt.Color;importjava.awt.Graphics;publicclassChess{intid;intchess_x;intchess_y;intstate;intradius=13;publicChess(){}publicChess(intid,intchess_x,intchess_y,intstate){this.id=id;this.chess_x=chess_x;this.chess_y=chess_y;this.state=
2、state;}publicintgetChess_x(){returnchess_x;}publicvoidsetChess_x(intchess_x){this.chess_x=chess_x;}publicintgetChess_y(){returnchess_y;}publicvoidsetChess_y(intchess_y){this.chess_y=chess_y;}publicintgetState(){returnstate;}publicvoidsetState(intstate){this.s
3、tate=state;}publicintgetId(){returnid;}publicvoidsetId(intid){this.id=id;}publicvoiddrawChess(Graphicsg){...Colorcolor=null;if(state==1){color=newColor(255,255,255);g.setColor(color);g.fillOval(chess_x*30-radius,chess_y*30-radius,radius*2,radius*2);}elseif(st
4、ate==-1){color=newColor(0,0,0);g.setColor(color);g.fillOval(chess_x*30-radius,chess_y*30-radius,radius*2,radius*2);}}}packageFiveChess;importjava.awt.Graphics;publicclassChessBoard{int[][]board=newint[16][16];publicChessBoard(){initialBoard();}publicvoidiniti
5、alBoard(){for(inti=0;i6、length){g.drawLine(i*30,30,i*30,15*30);i++;}while(j0&y>0&x<16&y<16)returnboard[x][y];elsereturn-2;}publicvoidsetState(intx,inty,intstate){board[x][y]=state;}}packageFiveC7、hess;importjava.awt.BorderLayout;importjava.awt.Color;importjava.awt.Dimension;importjava.awt.Image;importjava.awt.TextArea;importjava.awt.Toolkit;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.awt.event.KeyListener;importjava8、.awt.event.WindowAdapter;importjava.awt.event.WindowEvent;importjava.io.IOException;importjava.net.ServerSocket;importjava.net.Socket;importjava.sql.Time;importjavax.swing.ImageIcon;impor
6、length){g.drawLine(i*30,30,i*30,15*30);i++;}while(j0&y>0&x<16&y<16)returnboard[x][y];elsereturn-2;}publicvoidsetState(intx,inty,intstate){board[x][y]=state;}}packageFiveC
7、hess;importjava.awt.BorderLayout;importjava.awt.Color;importjava.awt.Dimension;importjava.awt.Image;importjava.awt.TextArea;importjava.awt.Toolkit;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.awt.event.KeyListener;importjava
8、.awt.event.WindowAdapter;importjava.awt.event.WindowEvent;importjava.io.IOException;importjava.net.ServerSocket;importjava.net.Socket;importjava.sql.Time;importjavax.swing.ImageIcon;impor
此文档下载收益归作者所有