三字棋Java程序设计_六子棋Java程序设计.docx

六子棋Java程序设计

六子棋Java程序设计作者:刘庆淘QQ号:543780889学号:111101009个人简介:宜宾学院,计算机学院11级创新班学生本程序简介: 对于玩家而言,我就是想让大家也让自己体验玩六子棋的乐趣。不过有点可惜就是,我至今还没有捣鼓出智能地算法出来,愿各位海涵。我还有的一个想法就是想与各位大精于java程序设计的大神们交流和学习。以下为本程序的源代码: 里们总共三个java文件皆放在了text包里:1:Myframe.javapackage text;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JFrame;import javax.swing.JMenu;import javax.swing.JMenuBar;import javax.swing.JMenuItem;public class Myframe extends JFrame implements ActionListener{MyPanel panel=new MyPanel();public Myframe(){JMenuBar menu =new JMenuBar();setJMenuBar(menu);JMenu game=new JMenu("游戏");JMenuItem newgame=game.add("新游戏");newgame.addActionListener(this);JMenu help = new JMenu("帮助");JMenuItem about=help.add("游戏规则");menu.add(game); menu.add(help); add(panel); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pack(); setTitle("六子棋"); setVisible(true); setResizable(false); }public void actionPerformed(ActionEvent arg0) {panel.game_start();panel.repaint();}}该文件主要是用构建框架2:MyPanel.javapackage text;import java.awt.Color;import java.awt.Dimension;import java.awt.Graphics;import java.awt.Point;import java.awt.event.MouseEvent;import java.awt.event.MouseListener;import java.util.ArrayList;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;public class MyPanel extends JPanel{ private ArrayList pointList; private int[][] b=new int[4][4];//黑子 private int[][] w=new int[4][4];//白子 private int[][] bi=new int[4][4];//黑子映射 private int[][] wi=new int[4][4];//白子映射 private int[][] all=new int[4][4]; //0表示无子,1表示有子。 int be,we; //b_end w_end int[][] f=new int[4][4];//聚焦点 int[][] fg=new int[4][4];//聚焦点周围 int[][] m=new int[4][4];//移子 int mx = 0;int my =0; int[] d=new int[4]; //direction 移子方向 0,1,2,3分别,上右下左 int r;//判断黑子走还是白子走,0是黑子走,1是白子走。 //构造函数 public MyPanel() { super.setBackground(Color.gray); pointList=new ArrayList(); setPreferredSize(new Dimension(200,240)); super.addMouseListener(new mylistener()); game_start(); }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值