java怎么写联机java五子棋实验报告

Java写出一个五子棋的代码怎么写?_百度知道
Java写出一个五子棋的代码怎么写?
答题抽奖
首次认真答题后
即可获得3次抽奖机会,100%中奖。
else严卫Wyanej
来自电脑网络类芝麻团
else严卫Wyanej
采纳数:370
获赞数:62
擅长:暂未定制
参与团队:
// 运行代码很简单:在eclipse的项目中新建一个类Five.java 把下面的代码放入该类即可 // 游戏运行:上下左右键控制方向,enter键确定棋子落定之处,黑白交替执行 import java.awt.*; import java.awt.event.*; import javax.swing.*; /** * 借鉴...
为你推荐:
其他类似问题
您可能关注的内容
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。为了账号安全,请及时绑定邮箱和手机
用Java写一个判断五子棋5个棋子相连的方法
只用写一个完整的方法,就是判断输赢。实在想不出,求解答。谢谢
有个课程讲Java做五子棋的 http://www.imooc.com/view/641
你还没有登录,请先登录或注册慕课网帐号
78957人关注
Copyright (C) 2018 imooc.com All Rights Reserved | 京ICP备 号-11想用Java 做五子棋游戏而且是多线程的应该怎么做_百度知道
想用Java 做五子棋游戏而且是多线程的应该怎么做
答题抽奖
首次认真答题后
即可获得3次抽奖机会,100%中奖。
兄弟连教育北京总校
专注培养IT技术人才
兄弟连教育北京总校
兄弟连IT教育专注PHP培训,JAVA培训,大数据培训,HTML5培训,UI培训,Linux培训,python培训,云计算培训。是中国最大的移动开发高端人才教育平台,也是中国移动互联网研发人才一体化服务的领导者!
直接上程序吧://wuziqi.java import java.applet.Aimport java.awt.Bimport java.awt.Cimport java.awt.CheckboxGimport java.awt.Cimport java.awt.Gimport java.awt.Limport java.awt.event.ActionEimport java.awt.event.ActionLimport java.awt.event.ItemEimport java.awt.event.ItemLimport java.awt.event.MouseEimport java.awt.event.MouseLimport java.awt.event.MouseMotionL
@SuppressWarnings(&serial&)public class wuziqi extends Applet implements ActionListener,MouseListener,MouseMotionListener,ItemListener { int color_Qizi=0;//旗子的颜色标识 0:白子 1:黑子 int intGame_Start=0;//游戏开始标志 0未开始 1游戏中 int intGame_Body[][]=new int[16][16]; //设置棋盘棋子状态 0 无子 1 白子 2 黑子 Button b1=new Button(&游戏开始&); Button b2=new Button(&重置游戏&); Label lblWin=new Label(& &); Checkbox ckbHB[]=new Checkbox[2]; CheckboxGroup ckgHB=new CheckboxGroup(); public void init() { setLayout(null); addMouseListener(this); add(b1); b1.setBounds(330,50,80,30); b1.addActionListener(this); add(b2); b2.setBounds(330,90,80,30); b2.addActionListener(this); ckbHB[0]=new Checkbox(&白子先&,ckgHB,false); ckbHB[0].setBounds(320,20,60,30); ckbHB[1]=new Checkbox(&黑子先&,ckgHB,false); ckbHB[1].setBounds(380,20,60,30); add(ckbHB[0]); add(ckbHB[1]); ckbHB[0].addItemListener(this); ckbHB[1].addItemListener(this); add(lblWin); lblWin.setBounds(330,130,80,30); Game_start_csh(); } public void itemStateChanged(ItemEvent e) { if (ckbHB[0].getState()) //选择黑子先还是白子先 { color_Qizi=0; } else { color_Qizi=1; } } public void actionPerformed(ActionEvent e) { @SuppressWarnings(&unused&)Graphics g=getGraphics(); if (e.getSource()==b1) { Game_start(); } else { Game_re(); } } public void mousePressed(MouseEvent e){} @SuppressWarnings(&unused&)public void mouseClicked(MouseEvent e) { Graphics g=getGraphics(); int x1,y1; x1=e.getX(); y1=e.getY(); if (e.getX()&20 || e.getX()&300 || e.getY()&20 || e.getY()&300) {
} if (x1%20&10) { x1+=20; } if(y1%20&10) { y1+=20; } x1=x1/20*20; y1=y1/20*20; set_Qizi(x1,y1); } public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mouseReleased(MouseEvent e){} public void mouseDragged(MouseEvent e){} public void mouseMoved(MouseEvent e){} public void paint(Graphics g) { draw_qipan(g); } public void set_Qizi(int x,int y) //落子 { if (intGame_Start==0) //判断游戏未开始 {
} if (intGame_Body[x/20][y/20]!=0) {
} Graphics g=getGraphics(); if (color_Qizi==1)//判断黑子还是白子 { g.setColor(Color.black); color_Qizi=0; } else { g.setColor(Color.white); color_Qizi=1; } g.fillOval(x-10,y-10,20,20); intGame_Body[x/20][y/20]=color_Qizi+1; if (Game_win_1(x/20,y/20)) //判断输赢 { lblWin.setText(Get_qizi_color(color_Qizi)+&赢了!&); intGame_Start=0; } if (Game_win_2(x/20,y/20)) //判断输赢 { lblWin.setText(Get_qizi_color(color_Qizi)+&赢了!&); intGame_Start=0; } if (Game_win_3(x/20,y/20)) //判断输赢 { lblWin.setText(Get_qizi_color(color_Qizi)+&赢了!&); intGame_Start=0; } if (Game_win_4(x/20,y/20)) //判断输赢 { lblWin.setText(Get_qizi_color(color_Qizi)+&赢了!&); intGame_Start=0; } } public String Get_qizi_color(int x) { if (x==0) { return &黑子&; } else { return &白子&; } } public void draw_qipan(Graphics G) //画棋盘 15*15 { G.setColor(Color.lightGray); G.fill3DRect(10,10,300,300,true); G.setColor(Color.black); for(int i=1;i&16;i++) { G.drawLine(20,20*i,300,20*i); G.drawLine(20*i,20,20*i,300); } } public void Game_start() //游戏开始 { intGame_Start=1; Game_btn_enable(false); b2.setEnabled(true); } public void Game_start_csh() //游戏开始初始化 { intGame_Start=0; Game_btn_enable(true); b2.setEnabled(false); ckbHB[0].setState(true); for (int i=0;i&16 ;i++ ) { for (int j=0;j&16 ;j++ ) { intGame_Body[i][j]=0; } } lblWin.setText(&&); } public void Game_re() //游戏重新开始 { repaint(); Game_start_csh(); } public void Game_btn_enable(boolean e) //设置组件状态 { b1.setEnabled(e); b2.setEnabled(e); ckbHB[0].setEnabled(e); ckbHB[1].setEnabled(e); } public boolean Game_win_1(int x,int y) //判断输赢 横 { int x1,y1,t=1; x1=x; y1=y; for (int i=1;i&5 ;i++ ) { if (x1&15) {
} if (intGame_Body[x1+i][y1]==intGame_Body[x][y]) { t+=1; } else {
} } for (int i=1;i&5 ;i++ ) { if (x1&1) {
} if(intGame_Body[x1-i][y1]==intGame_Body[x][y]) { t+=1; } else {
} } if (t&4) {
} } public boolean Game_win_2(int x,int y) //判断输赢 竖 { int x1,y1,t=1; x1=x; y1=y; for (int i=1;i&5 ;i++ ) { if (x1&15) {
} if (intGame_Body[x1][y1+i]==intGame_Body[x][y]) { t+=1; } else {
} } for (int i=1;i&5 ;i++ ) { if (x1&1) {
} if(intGame_Body[x1][y1-i]==intGame_Body[x][y]) { t+=1; } else {
} } if (t&4) {
} } public boolean Game_win_3(int x,int y) //判断输赢 左斜 { int x1,y1,t=1; x1=x; y1=y; for (int i=1;i&5 ;i++ ) { if (x1&15) {
} if (intGame_Body[x1+i][y1-i]==intGame_Body[x][y]) { t+=1; } else {
} } for (int i=1;i&5 ;i++ ) { if (x1&1) {
} if(intGame_Body[x1-i][y1+i]==intGame_Body[x][y]) { t+=1; } else {
} } if (t&4) {
} } public boolean Game_win_4(int x,int y) //判断输赢 左斜 { int x1,y1,t=1; x1=x; y1=y; for (int i=1;i&5 ;i++ ) { if (x1&15) {
} if (intGame_Body[x1+i][y1+i]==intGame_Body[x][y]) { t+=1; } else {
} } for (int i=1;i&5 ;i++ ) { if (x1&1) {
} if(intGame_Body[x1-i][y1-i]==intGame_Body[x][y]) { t+=1; } else {
} } if (t&4) {
为你推荐:
其他类似问题
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。&>&用JAVA编写的五子棋网络对战(附源代码)
用JAVA编写的五子棋网络对战(附源代码)
上传大小:255KB
用JAVA编写的五子棋网络对战,先建立一个游戏主机,然后客户端刷新主机,选中主机名称,然后建立连接。双方确认下棋即可下棋
综合评分:4
{%username%}回复{%com_username%}{%time%}\
/*点击出现回复框*/
$(".respond_btn").on("click", function (e) {
$(this).parents(".rightLi").children(".respond_box").show();
e.stopPropagation();
$(".cancel_res").on("click", function (e) {
$(this).parents(".res_b").siblings(".res_area").val("");
$(this).parents(".respond_box").hide();
e.stopPropagation();
/*删除评论*/
$(".del_comment_c").on("click", function (e) {
var id = $(e.target).attr("id");
$.getJSON('/index.php/comment/do_invalid/' + id,
function (data) {
if (data.succ == 1) {
$(e.target).parents(".conLi").remove();
alert(data.msg);
$(".res_btn").click(function (e) {
var parentWrap = $(this).parents(".respond_box"),
q = parentWrap.find(".form1").serializeArray(),
resStr = $.trim(parentWrap.find(".res_area_r").val());
console.log(q);
//var res_area_r = $.trim($(".res_area_r").val());
if (resStr == '') {
$(".res_text").css({color: "red"});
$.post("/index.php/comment/do_comment_reply/", q,
function (data) {
if (data.succ == 1) {
var $target,
evt = e || window.
$target = $(evt.target || evt.srcElement);
var $dd = $target.parents('dd');
var $wrapReply = $dd.find('.respond_box');
console.log($wrapReply);
//var mess = $(".res_area_r").val();
var mess = resS
var str = str.replace(/{%header%}/g, data.header)
.replace(/{%href%}/g, 'http://' + window.location.host + '/user/' + data.username)
.replace(/{%username%}/g, data.username)
.replace(/{%com_username%}/g, data.com_username)
.replace(/{%time%}/g, data.time)
.replace(/{%id%}/g, data.id)
.replace(/{%mess%}/g, mess);
$dd.after(str);
$(".respond_box").hide();
$(".res_area_r").val("");
$(".res_area").val("");
$wrapReply.hide();
alert(data.msg);
}, "json");
/*删除回复*/
$(".rightLi").on("click", '.del_comment_r', function (e) {
var id = $(e.target).attr("id");
$.getJSON('/index.php/comment/do_comment_del/' + id,
function (data) {
if (data.succ == 1) {
$(e.target).parent().parent().parent().parent().parent().remove();
$(e.target).parents('.res_list').remove()
alert(data.msg);
//填充回复
function KeyP(v) {
var parentWrap = $(v).parents(".respond_box");
parentWrap.find(".res_area_r").val($.trim(parentWrap.find(".res_area").val()));
评论共有7条
不能刷新啊,好着急
还不错,值得参考
还不错。没事的时候可以研究
VIP会员动态
热门资源标签
CSDN下载频道资源及相关规则调整公告V11.10
下载频道用户反馈专区
下载频道积分规则调整V1710.18
spring mvc+mybatis+mysql+maven+bootstrap 整合实现增删查改简单实例.zip
资源所需积分/C币
当前拥有积分
当前拥有C币
输入下载码
为了良好体验,不建议使用迅雷下载
用JAVA编写的五子棋网络对战(附源代码)
会员到期时间:
剩余下载个数:
剩余积分:0
为了良好体验,不建议使用迅雷下载
积分不足!
资源所需积分/C币
当前拥有积分
您可以选择
程序员的必选
绿色安全资源
资源所需积分/C币
当前拥有积分
当前拥有C币
为了良好体验,不建议使用迅雷下载
资源所需积分/C币
当前拥有积分
当前拥有C币
为了良好体验,不建议使用迅雷下载
资源所需积分/C币
当前拥有积分
当前拥有C币
您的积分不足,将扣除 10 C币
为了良好体验,不建议使用迅雷下载
无法举报自己的资源
你当前的下载分为234。
你还不是VIP会员
开通VIP会员权限,免积分下载
你下载资源过于频繁,请输入验证码
您因违反CSDN下载频道规则而被锁定帐户,如有疑问,请联络:!
若举报审核通过,可返还被扣除的积分
被举报人:
zhangwei0407
请选择类型
资源无法下载 ( 404页面、下载失败、资源本身问题)
资源无法使用 (文件损坏、内容缺失、题文不符)
侵犯版权资源 (侵犯公司或个人版权)
虚假资源 (恶意欺诈、刷分资源)
含色情、危害国家安全内容
含广告、木马病毒资源
*投诉人姓名:
*投诉人联系方式:
*版权证明:
*详细原因:
用JAVA编写的五子棋网络对战(附源代码)java实现联机五子棋
&& 来源:open-open
版权申明:本站文章部分自网络,如有侵权,请联系028-0 邮箱:
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
400-028-5800

我要回帖

更多关于 儿童五子棋教学视频 的文章

 

随机推荐