## 用面向对象思想设计奥赛罗游戏 原

一贱书生

1. Game()为主函数，来管理游戏中的所有活动
2.构造函数对游戏进行初始化
3.获取第一个玩家的输入
4.验证输入
5.更改棋盘格局
6.检验是否有人获胜了
7.获取第二个玩家的输入

 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 public class Question {     private final int white = 1;     private final int black = 2;     private int[][]  board;       /* Sets up the board in the standard othello starting positions,      * and starts the game */       public void start () { ... }       /* Returns the winner, if any. If there are no winners, returns      * 0 */       private int won() {     if (!canGo (white) && !canGo (black)) {       int count = 0;         for (int i = 0; i < 8; i++) {           for (int j = 0; j < 8; j++) {             if (board [i] [j] == white) {               count++;             }               if (board [i] [j] == black) {               count--;             }           }           }           if (count > 0) return white;           if (count < 0) return black;           return 3;       }       return 0;     }       /* Returns whether the player of the specified color has a valid      * move in his turn. This will return false when      * 1. none of his pieces are present      * 2. none of his moves result in him gaining new pieces      * 3. the board is filled up      */     private boolean canGo(int color) { ... }       /* Returns if a move at coordinate (x,y) is a valid move for the      * specified player */     private boolean isValid(int color, int x, int y) { ... }       /* Prompts the player for a move and the coordinates for the move.      * Throws an exception if the input is not valid or if the entered      * coordinates do not make a valid move. */     private void getMove (int color) throws Exception { ... }       /* Adds the move onto the board, and the pieces gained from that      * move. Assumes the move is valid. */     private  void add (int x, int y, int  color) { ... }       /* The actual game: runs continuously until a player wins */       private void game() {         printBoard();       while (won() == 0) {           boolean valid = false;           while (!valid) {           try {               getMove(black);               valid = true;           } catch (Exception e) {               System.out.println (“Enter a valid coordinate!”);           }           }           valid = false;           printBoard();           while (!valid) {           try {               getMove(white);               valid = true;           } catch (Exception e) {               System.out.println (“Enter a valid coordinate!”);           }           }           printBoard ();       }         if (won()!=3) {         System.out.println (won () == 1 ? “white” : “black” +                    “ won!”);       } else {         System.out.println(“It’s a draw!”);         }     }   }   参考：http://wenku.baidu.com/view/47eda066f8c75fbfc67db27f.html

### 一贱书生

【成都】天上友嘉2~10K招聘PHP、AS开发

PHP开发高级工程师 岗位职责： 1. 将项目策划转换成软件需要进行需要分析、设计； 2. 负责项目的代码实现、单元测试； 3. 负责项目部署、调试、更新以及优化； 4. 担任对部门新进员工的培养指...

2011/07/15
493
3
【成都】某游戏公司诚意招聘PHP开发人员

Youkia
2012/04/19
475
4
【北京】7K7K招聘高级JS前端/高级AS3程序（20K左右）

7K7K是目前国内做大的休闲网页游戏平台之一，参见网站：www.7k7k.com 高级JS前端： 1、专科及以上学历，计算机相关专业； 2、有5年以上前端开发的相关开发经验，熟悉JavaScript、ajax、XML、...

2012/04/11
1K
9

*楚狂人*
2012/03/12
514
2
【上海招聘】大型游戏招聘C++客户端/服务器工程师，Flash开发工程师，以及游戏开发相关职位

2011/10/20
717
2

[LintCode] Serialize and Deserialize Binary Tree（二叉树的序列化和反序列化）

honeymose

5
0
java框架学习日志-7（静态代理和JDK代理）

23
0

1.Flink窗口 Window Assigner分配器。 窗口可以是时间驱动的（Time Window，例如：每30秒钟），也可以是数据驱动的（Count Window，例如：每一百个元素）。 一种经典的窗口分类可以分成： 翻...

18
0
my.ini

1

architect刘源源

16
0
docker dns

There is a opensource application that solves this issue, it's called DNS Proxy Server It's a DNS server that solves containers hostnames, if could not found a hostname that mat......

kut

16
0