20162323周楠 2017-2018-1 《程序设计与数据结构》实验报告五
20162323周楠 2017-2018-1 《程序设计与数据结构》实验报告五
目录预览
实验五-1-编译、运行、测试
编译、运行、测试

实验过程
- 1.先将代码上传至码云的项目里
码云链接:bug终结者 - 2.按照老师的要求新建一个“20162323_zhounan_exp5"的文件夹
因为我的电脑是Mac,所以在桌面建文件夹,然后用终端Git
![]()
- 3.在android studio中重新clone,将项目放在文件夹“20162323_zhounan_exp5”中
![]()
- 4.运行
![]()
![]()
实验四-图的实现与应用-2
实验五-2-代码修改

实验过程
对关卡和按键进行了修改



实验五-3-代码分析
实验过程
- 1.数据结构的应用情况及相关代码
public static int [] Steps;
public static final int FLOOR = 1; //地板
public static final int NOTHING = 0; //没有
public static final int BOX = 4; //该单元格放的是箱子
public static final int FLAG = 2; //红旗,表示箱子的目的地
public static final int MAN = 5; //搬运工
public static final int WALL = 3; //墙
public static final int MAN_FLAG = 5; //搬运工 + 小球
public static final int BOX_FLAG = 6; //箱子 + 小球
public static final int [][] LEVEL_1 = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 3, 2, 3, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 3, 1, 3, 3, 3, 3, 0, 0, 0, 0},
{0, 0, 0, 0, 3, 3, 3, 4, 1, 4, 2, 3, 0, 0, 0, 0},
{0, 0, 0, 0, 3, 2, 1, 4, 5, 3, 3, 3, 0, 0, 0, 0},
{0, 0, 0, 0, 3, 3, 3, 3, 4, 3, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 3, 2, 3, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
};
public GameState(int[][] initialState){
//获得的地图数组
mLabelInCells = initialState;
//新建一个栈
stack = new Stack<>();
//生成一个地图大小的数组
temp = new int[initialState.length][initialState[0].length];
for (int i = 0; i < initialState.length; i++)
for(int j=0;j<initialState[i].length;j++) {
temp[i][j] = initialState[i][j];
mLabelInCells[i][j] = initialState[i][j];
}
get_gongren_chushi_weizhi(); //根据游戏开局初始化搬运工的位置
}
- 2.查找算法的应用情况及相关代码
for (int r = 0; r < labelInCells.length; r++) //逐行地扫描矩阵
for (int c = 0; c < labelInCells[r].length; c++){ //对当前行r,逐列地扫描
destRect = getRect(r, c); //得到图片在屏幕中的显示区域
srcRect = new Rect(0, 0,GameBitmaps.FlagBitmap.getWidth(), GameBitmaps.FlagBitmap.getHeight());//获得显示图片的大小
switch (labelInCells[r][c]){
case 1:
canvas.drawBitmap(GameBitmaps.FloorBitmap,srcRect,destRect,null); //绘制地板
break;
case 2:
canvas.drawBitmap(GameBitmaps.FlagBitmap, srcRect, destRect, null); //绘制标记
break;
case 3:
canvas.drawBitmap(GameBitmaps.WallBitmap, srcRect, destRect, null); //绘制墙
break;
case 4:
canvas.drawBitmap(GameBitmaps.BoxBitmap, srcRect, destRect, null); //绘制箱子
break;
case 5:
canvas.drawBitmap(GameBitmaps.ManBitmap, srcRect, destRect, null); //绘制人
break;
case 6:
canvas.drawBitmap(GameBitmaps.ReadboxBitmap, srcRect, destRect, null); //绘制红箱子
break;
}
}
感悟
这周因为一些家庭私人原因,精力非常不够用,自己也非常疲惫,导致博客晚交,非常感谢老师对我的宽容和理解,真的非常非常的谢谢。这周的小思考,生命是非常脆弱的,不管是你的家人,还是远在这世界角落的任何一个人,珍惜与家人在一起的时间,时间太晚了也说不出煽情的话,总之,感谢各位老师对我的宽容和理解,真的真的真的很谢谢你们。
代码托管
PSP(Personal Software Process)时间
| 步骤 | 耗时 | 百分比 |
|---|---|---|
| 需求分析 | 40min | 6% |
| 代码实现 | 500min | 75.8% |
| 测试 | 90min | 13.6% |
| 总结 | 30min | 4.6% |




浙公网安备 33010602011771号