广告广告
  加入我的最爱 设为首页 风格修改
首页 首尾
 手机版   订阅   地图  繁体 
您是第 3933 个阅读者
 
发表文章 发表投票 回覆文章
  可列印版   加为IE收藏   收藏主题   上一主题 | 下一主题   
史小比
数位造型
个人文章 个人相簿 个人日记 个人地图
路人甲
级别: 路人甲 该用户目前不上站
推文 x0 鲜花 x0
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片
推文 x0
[Java][求助] 可以帮我说明"井字游戏"的程式流程吗?
import java.awt.*;
import java.awt.event.*;
public class OXMain extends Frame implements ActionListener {
private OX oxBoard;
private OXMain() {
super("井字游戏");
Menu m;
MenuBar mb;
oxBoard = new OX(this);
this.add(oxBoard);
CloseWindow close = new CloseWindow(this, true);
this.setMenuBar(mb = new MenuBar());
mb.add(m = new Menu("游戏")).add(new MenuItem("新游戏")).addActionListener(this);
m.add(new MenuItem("结束")).addActionListener(close);
mb.add(new Menu("说明")).add(new MenuItem("关于本游戏")).addActionListener(this);
this.addWindowListener(close);
this.pack();
this.show();
}
public static void main(String argv[]) {
new OXMain();
}
// implements the ActionListener interface
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if (command.equals("关于本游戏")) {
new ErrorDialog(this,"俞旭升写好玩的");
} else if (command.equals("新游戏")) {
oxBoard.newGame();
}
}
}
class OX extends Component implements MouseListener {
public static final byte EMPTY = 0;
public static final byte CIRCLE = 1;
public static final byte CROSS = 2;
private byte[] board = new byte;
private byte playing = CIRCLE;
private Dimension mySize = new Dimension(300,300);
private Frame parent;
private byte[][] directions = {{0,1,2},{3,4,5},{6,7,8},{0,3,6},{1,4,7},{2,5,8},{0,4,8},{2,4,6}};
public OX(Frame p) {
this.addMouseListener(this);
parent = p;
}
// The following 5 functions implement the MouseListener interface
public void mouseClicked(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
public void mousePressed(MouseEvent e) {
int row = e.getY()/100;
int col = e.getX()/100;
if (row >= 3 || col >= 3) return; // 超过边界
if (board == EMPTY) { // 此位置可以下
board = playing;
repaint(); // notify Window Manager
// Anyone Win?
for (int i=0; i<directions.length; i++) {
int j;
for (j=0; j<3 && board] ..

访客只能看到部份内容,免费 加入会员 或由脸书 Google 可以看到全部内容




献花 x0 回到顶端 [楼 主] From:欧洲 | Posted:2008-04-03 17:20 |
daviddr
个人文章 个人相簿 个人日记 个人地图
小人物
级别: 小人物 该用户目前不上站
推文 x0 鲜花 x7
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片

(※1.一段一段解释给我听
2.用打-解释给我)
^^^^^^^^^^^^^
还命令句咧...... 真好笑.....


献花 x0 回到顶端 [1 楼] From:台湾中华 | Posted:2008-05-26 02:01 |

首页  发表文章 发表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.016596 second(s),query:16 Gzip disabled
本站由 瀛睿律师事务所 担任常年法律顾问 | 免责声明 | 本网站已依台湾网站内容分级规定处理 | 连络我们 | 访客留言