资源简介
checker 国际跳棋 游戏 可以运行。

代码片段和文件信息
/**
MVC programming
G. Volger
12.9.04
This is the Model - CheckerBoard.java
The model (CheckerGame) the view (CheckersView) and the controller
(Checkers) are in separate files. When the model changes the view is
notified and updated automatically.
*/
/*
The checker board is an 8 x 8 grid with the top left corner being
a white square. All pieces (White & Green) reside on black squares.
Red squares are never occupied.
*/
import java.util.Observable;
public class CheckerBoard // NEED TO EXTEND A CLASS TO MAKE MVC WORK
{
private int board[][];
private int BOARD_SIZE = 8;
private int EMPTY = 0;
private static int Player_ONE = 1;
private static int Player_TWO = 2;
private static int KING_ME = 2;
/**
* Creates an checkerboard with all the pieces in their starting places.
*/
public CheckerBoard()
{
board = new int[BOARD_SIZE][BOARD_SIZE];
clearBoard();
setPlayers();
}
/**
Sets all the board locations to empty
*/
private void clearBoard()
{
for (int r = 0; r < BOARD_SIZE; r++)
for (int c = 0; c < BOARD_SIZE; c++)
board[r][c] = EMPTY;
}
/**
* Places the check board pieces in their starting locations
*/
private void setPlayers()
{
// Top player pieces in first three rows
for (int r = 0; r < 3; r++)
{
int start;
if ( r % 2 == 0)
start = 1;
else
start = 0;
for (int c = start; c < BOARD_SIZE; c = c + 2)
{
board[r][c] = Player_ONE;
}
}
// Bottom player pieces in bottom three rows
for (int r = BOARD_SIZE - 3; r < BOARD_SIZE; r++)
{
int start;
if ( r % 2 == 0)
start = 1;
else
start = 0;
for (int c = start; c < 8; c = c + 2)
{
board[r][c] = Player_TWO;
}
}
}
/**
Returns true if r & c are within the board
@param r row location of checkerboard
@param c column location of checkerboard
@return returns true if r & c are valid locations in the checkerboard
*/
public boolean validLocation(int r int c)
{
if (r < 0 || r >= BOARD_SIZE || c < 0 || c >= BOARD_SIZE)
return false;
return true;
}
/**
Black squares can be found in
Even Row & Odd Column
Odd Row & Even Column
@param r row location of checkerboard
@param c column location of checkerboard
@return returns true if location (rc) is a black square on the checkerboard
*/
public boolean blackSqaure(int r int c)
{
if (!validLocation(r c))
return false;
if (r % 2 == 0)
return (c % 2 != 0);
return (c % 2 == 0);
}
/**
@param r row location of checkerboard
@param c column location of checkerboard
@return returns true is there is a checker piece on the grid location (rc)
otherwise returns false
*/
public boolean sqaureOccupied(int r int c)
{
if (!validLocation(rc))
return false;
return board[r][c] != EMPTY;
}
/**
@param myRow row location of checkerboard
@param myCol column location of checkerboard
@param oppRow row location of checkerboard
@param oppCol column location of checke
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-03-03 10:39 Checker\
文件 295 2014-02-02 17:34 Checker\.classpath
文件 6148 2014-03-13 20:56 Checker\.DS_Store
目录 0 2014-03-13 20:56 __MACOSX\
目录 0 2014-03-13 20:56 __MACOSX\Checker\
文件 120 2014-03-13 20:56 __MACOSX\Checker\._.DS_Store
文件 366 2014-02-02 17:34 Checker\.project
目录 0 2014-02-02 17:34 Checker\.settings\
文件 587 2014-02-02 17:34 Checker\.settings\org.eclipse.jdt.core.prefs
目录 0 2014-02-13 17:52 Checker\bin\
目录 0 2014-02-13 17:52 Checker\bin\application\
文件 1763 2014-02-13 17:52 Checker\bin\application\CheckerBoard.class
文件 1400 2014-02-13 17:52 Checker\bin\application\Checkers.class
文件 1749 2014-02-13 17:52 Checker\bin\application\CheckersView.class
目录 0 2014-03-03 10:39 Checker\src\
文件 6148 2014-03-13 20:56 Checker\src\.DS_Store
目录 0 2014-03-13 20:56 __MACOSX\Checker\src\
文件 120 2014-03-13 20:56 __MACOSX\Checker\src\._.DS_Store
目录 0 2014-02-02 17:41 Checker\src\application\
文件 9811 2014-02-02 17:40 Checker\src\application\CheckerBoard.java
文件 3190 2014-02-02 17:41 Checker\src\application\Checkers.java
文件 4291 2014-02-02 17:41 Checker\src\application\CheckersView.java
相关资源
- flash3.0小游戏
- Scrach 欢乐狙击手.sb2
- linux应用层的华容道游戏源代码
- 小鸡快跑游戏.
- [易语言]游戏多开例程
- 贪吃蛇游戏设计(汇编语言)
- VC 游戏编程—附源代码
- C 纸牌游戏——21点
- 分享 mud 文字游戏 源码
- c 制作的RPG小游戏
- 五子棋游戏实现悔棋功能
- 找不同FLASH游戏源码
- planeGame飞机游戏
- 拼图游戏源代码 powerbuilder 9.0实例
- 解决WPE进不了游戏的最佳方法(闭屏
- linux扫雷游戏代码
- 多线程实例:桌面智能弹球小游戏
- “猜数字”游戏 算法破解
- OpenGL-3D坦克模拟
- 联机版井字棋源码
- 拼图游戏(可自由选择难度)
- 扫雷(MVC架构)
- 解封SHOW 51VV 9158 封机器码类游戏机
- scratch穿越迷宫.sb2
- 小鱼捉迷藏Scratch小游戏
- GlowtoolsA-wdf网易游戏wdf查看及解包
- 游戏音频图像提取工具GARbro
- OPENGL实现世界上最小的3D游戏
- Scrach3.0 跳一跳小游戏
- js 迷宫小游戏源码
评论
共有 条评论