欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    Java写的围棋游戏的源代码.doc

    • 资源ID:79330151       资源大小:34KB        全文页数:10页
    • 资源格式: DOC        下载积分:15金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要15金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    Java写的围棋游戏的源代码.doc

    JavaдµÄΧÆåÓÎÏ·µÄÔ´´úÂë.txtÎÒµÄÈËÉúÓÐA ÃæÒ²ÓÐBÃ棬ÄãµÄÈËÉúÓÐSÃæÒ²ÓÐBÃæ¡£ ʧ°Ü²»¿ÉÅ£¬¹Ø¼ü¿´ÊDz»Êdzɹ¦ËûÂè¡£ÏÖÔڵĴóѧÉú̫ûËØÖÊÁË£¡¹ýÀ´¿½Ã«Æ¬£¬¾ÓÈ»ÓüôÇУ¡ÓпÕѧ·çˮȥ£¬ËÀºóÕ¼¸öºÃĹҲËãÃÖ²¹ÁËÉúÇ°Âò²»ÆðºÃ·¿µÄÒź¶¡£import java.awt.*;import java.awt.event.*;import javax.swing.JOptionPane;public class Chess extends Frame ChessPad chesspad= new ChessPad(); Chess() add(chesspad); chesspad.setBounds(70,90,440,440); Label label=new Label("click to point,doubled_click to remove,right click to back",Label.CENTER); add(label); label.setBounds(70,55,440,24); label.setBackground(Color.orange); addWindowListener ( new WindowAdapter() public void windowClosing(WindowEvent e) System.exit(0); ); setLayout(null); setVisible(true); setSize(600,550); public static void main(String args) Chess chess=new Chess(); class ChessPad extends Panel implements MouseListener, ActionListener,FocusListener int x = -1, y = -1, chessColor = 1; String blackname="",whitename="" Button button=new Button("start"); Button inputButton=new Button("input"); TextField text_1=new TextField("black please"), text_2=new TextField(""),/white please text_3=new TextField("black'name"), text_4=new TextField("white'name"); ChessPad() add(inputButton); inputButton.setBounds(35,5,60,26); inputButton.addActionListener(this); inputButton.addFocusListener(this); add(text_3); text_3.setBounds(115,5,90,24); text_3.addFocusListener(this); text_3.setEditable(true); add(text_4); text_4.setBounds(315,5,90,24); text_4.addFocusListener(this); text_4.setEditable(true); add(button); button.setBounds(35,36,60,26); button.setEnabled(false); button.addActionListener(this); add(text_1); text_1.setBounds(115,36,90,24); text_1.setEnabled(false); text_1.setEditable(false); add(text_2); text_2.setBounds(315,36,90,24); text_2.setEnabled(false); text_2.setEditable(false); setSize(440,440); setLayout(null); setBackground(Color.orange); addMouseListener(this); public void paint(Graphics g) for(int i=80;i<=400;i=i+20) g.drawLine(40,i,400,i); g.drawLine(40,420,400,420); for(int j=40;j<=380;j=j+20) g.drawLine(j,80,j,420); g.drawLine(400,80,400,420); g.fillOval(97,137,6,6); g.fillOval(337,137,6,6); g.fillOval(97,377,6,6); g.fillOval(337,377,6,6); g.fillOval(217,257,6,6); public void focusGained(FocusEvent e) Component com=(Component)e.getSource(); if(com=text_3) text_3.setText(""); else if(com=text_4) text_4.setText(""); public void focusLost(FocusEvent e) public void mousePressed(MouseEvent e) if(blackname.length()=0|whitename.length()=0) JOptionPane.showMessageDialog(this,"please input the player's name,and click input button before you start chess!","reminder",JOptionPane.WARNING_MESSAGE); else if(blackname.equals("black'name") JOptionPane.showMessageDialog(this,"please input the black player's name,and click input button","reminder",JOptionPane.WARNING_MESSAGE); else if(whitename.equals("white'name") JOptionPane.showMessageDialog(this,"please input the white player's name,and click input button","reminder",JOptionPane.WARNING_MESSAGE); else if(e.getModifiers()=InputEvent.BUTTON1_MASK) x = (int)e.getX(); y = (int)e.getY(); int a=(x+10)/20,b=(y+10)/20; ChessPoint_black chesspoint_black=new ChessPoint_black(this); ChessPoint_white chesspoint_white=new ChessPoint_white(this); if(x/20<2|y/20<4|x/20>19|y/20>20) else if(chessColor=1) this.add(chesspoint_black); chesspoint_black.setBounds(a*20-10,b*20-10,20,20); chessColor=chessColor*(-1); text_2.setText(this.whitename+" please"); text_1.setText(""); else if(chessColor=-1) this.add(chesspoint_white); chesspoint_white.setBounds(a*20-10,b*20-10,20,20); chessColor=chessColor*(-1); text_1.setText(this.blackname+" please"); text_2.setText(""); public void mouseReleased(MouseEvent e) public void mouseEntered(MouseEvent e) public void mouseExited(MouseEvent e) public void mouseClicked(MouseEvent e) public void actionPerformed(ActionEvent e) if(e.getSource()=inputButton) blackname=text_3.getText(); whitename=text_4.getText(); if(blackname.length()=0|whitename.length()=0) JOptionPane.showMessageDialog(this,"you did not complete the information!","reminder",JOptionPane.WARNING_MESSAGE); else if(blackname.equals("black'name") JOptionPane.showMessageDialog(this,"please input the black player's name","reminder",JOptionPane.WARNING_MESSAGE); else if(whitename.equals("white'name") JOptionPane.showMessageDialog(this,"please input the white player's name","reminder",JOptionPane.WARNING_MESSAGE); else inputButton.setEnabled(false); text_3.removeFocusListener(this); text_3.setEnabled(false); text_4.setEnabled(false); button.setEnabled(true); text_1.setEnabled(true); text_1.setText(blackname+" please"); text_2.setEnabled(true); else if(e.getSource()=button) inputButton.setEnabled(true); text_3.setEnabled(true); text_4.setEnabled(true); button.setEnabled(false); text_1.setEnabled(false); text_2.setEnabled(false); this.removeAll(); chessColor=1; add(button); button.setBounds(35,36,60,26); add(text_1); text_1.setBounds(115,36,90,24); text_1.setText("black please"); add(text_2); text_2.setBounds(315,36,90,24); text_2.setText(""); add(inputButton); inputButton.setBounds(35,5,60,26); add(text_3); text_3.setText("black'name"); text_3.addFocusListener(this); text_3.setBounds(115,5,90,24); add(text_4); text_4.setText("white'name"); text_4.setBounds(315,5,90,24); blackname="" whitename="" class ChessPoint_black extends Canvas implements MouseListener ChessPad chesspad=null; ChessPoint_black(ChessPad p) setSize(20,20); chesspad=p; addMouseListener(this); public void paint(Graphics g) g.setColor(Color.black); g.fillOval(0,0,20,20); public void mousePressed(MouseEvent e) if(e.getModifiers()=InputEvent.BUTTON3_MASK) chesspad.remove(this); chesspad.chessColor=1; chesspad.text_2.setText(""); chesspad.text_1.setText(chesspad.blackname+" please"); public void mouseReleased(MouseEvent e) public void mouseEntered(MouseEvent e) public void mouseExited(MouseEvent e) public void mouseClicked(MouseEvent e) if(e.getClickCount()>=2) chesspad.remove(this); class ChessPoint_white extends Canvas implements MouseListener ChessPad chesspad=null; ChessPoint_white(ChessPad p) setSize(20,20); chesspad=p; addMouseListener(this); public void paint(Graphics g) g.setColor(Color.white); g.fillOval(0,0,20,20); public void mousePressed(MouseEvent e) if(e.getModifiers()=InputEvent.BUTTON3_MASK) chesspad.remove(this); chesspad.chessColor=-1; chesspad.text_1.setText(""); chesspad.text_2.setText(chesspad.whitename+" please"); public void mouseReleased(MouseEvent e) public void mouseEntered(MouseEvent e) public void mouseExited(MouseEvent e) public void mouseClicked(MouseEvent e) if(e.getClickCount()>=2) chesspad.remove(this);

    注意事项

    本文(Java写的围棋游戏的源代码.doc)为本站会员(asd****56)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开