资源简介
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
相关资源
- STM32开发板设计贪吃蛇游戏
- Unity 消灭病毒游戏源码含详细的教程
- flash as3制作的连连看小游戏
- DirectX游戏
- VHDL写的拔河游戏机
- 斗地主游戏逻辑流程图
- 基于VGA和FPGA实现的打砖块反弹球游戏
- Flash拼图游戏源代码
- 基于51单片机LCDLM041L显示贪吃蛇小游戏
- 分享几个汇编语言写的游戏
- 非常优秀的棋牌类游戏源码,包含A
- Labview实现的11款小游戏.zip
- 象棋游戏人人,人机
- 弹球游戏(课程设计)
- 暗黑源代码
- 易语言战斗回合制游戏源代码
- Unity3D Flick Basketball 篮球游戏 完整源码
- 网页游戏素材提取器
- hcgconv 游戏解包工具
- 小游戏-接苹果游戏源代码
- AR跳舞游戏源码
- 基于stm32、0.96寸OLED实现的贪吃蛇小游
- 猜数字游戏 Flash源文件源码.rar
- Go-sanguo是一个golang手游服务器网络框
- 论文研究-FPS游戏中基于HTN的Anytime规划
- 接苹果.rar
- labview 实现贪吃蛇游戏
- webGL直接写的2d火爆射击游戏
- OpenCV 飞行游戏手势控制源码.rar
- 飞机大战素材包.zip
评论
共有 条评论