JAVA第三次实验

java

第三次实验

北京电子科技学院(BESTI)

实     验    报     告

课程:Java程序设计   班级:1353      姓名:王亦可  学号:20135326

成绩:             指导教师:娄嘉鹏      实验日期:

实验密级:         预习程度:             实验时间:

仪器组次:          必修/选修:选修       实验序号:3

实验名称:                敏捷开发与XP实践                           

实验目的与要求:                                                        

完成实验、撰写实验报告,实验报告以博客方式发表在博客园,注意实验报告重点是运行结果,遇到的问题(工具查找,安装,使用,程序的编辑,调试,运行等)、解决办法(空洞的方法如“查网络”、“问同学”、“看书”等一律得0分)以及分析(从中可以得到什么启示,有什么收获,教训等)。报告可以参考范飞龙老师的指导                             

                                                                     

实验仪器:

名称

型号

数量

Pc

 

1

 

 

 

重构:

一、一个完整的重构流程包括:

  1. 从版本控制系统代码库中Check out code
  2. 读懂代码(包括测试代码)
  3. 发现bad smell
  4. Refactoring
  5. 运行所有的Unit Tests
  6. 往代码库中Check in code

二、重构技能

三、何时需要重构

TDD测试:

 四、游戏:扫雷

import static org.junit.Assert.*;

import org.junit.Test;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;

import MyFrame.Constant;
public class testTank {
private int x,y;
private int wid=Constant.WW;
private int hei=Constant.WH;
public int tet(int x, int y) {
this.x = x;
this.y = y;
return 0;
}
public void draw(Graphics g){
Color c=g.getColor();
g.setColor(Color.GRAY);
g.fillRect(x, y, wid, hei);
g.setColor(c);
}
public Rectangle getRect(){
return new Rectangle(x,y,wid,hei);
}

@Test
public void test() {

assertEquals(0,tet(1,1));
}

}

package com.sf.minesweeper.bean;

import javax.swing.JLabel;
/**
* 自定义标签(雷块)
*/
public class MineLabel extends JLabel {

private static final long serialVersionUID = -7271927020145498558L;

/**
* 判断是否是雷

* */
private boolean isMine;
/**
* 判断雷块是否展开

* */
private boolean isExpanded;
/**
* 判断雷块是否是旗子

* */
private boolean isFlag;
/**
* 判断是否是雷且未标上旗子
* */
private boolean isMineAndNotflag;
/**
* count 计算雷块周围的雷数

* */
private int mineCount;
/**
* 雷块所在的行

* */
private int rowIndex;
/**
* 雷块所在的列

* */
private int colIndex;


private int expend=0;

//雷区上的行列坐标
public MineLabel(int rowIndex, int colIndex) {
this.rowIndex = rowIndex;
this.colIndex = colIndex;
}
//一向是对应的一些get和set方法
public boolean isMine() {
return isMine;
}

public void setMine(boolean isMine) {
this.isMine = isMine;
}

public boolean isExpanded() {
return isExpanded;
}

public void setExpanded(boolean isExpanded) {
this.isExpanded = isExpanded;
}

public boolean isFlag() {
return isFlag;
}

public void setFlag(boolean isFlag) {
this.isFlag = isFlag;
}

public int getMineCount() {
return mineCount;
}

public void setMineCount(int mineCount) {
this.mineCount = mineCount;
}

public int getRowIndex() {
return rowIndex;
}

public void setRowIndex(int rowIndex) {
this.rowIndex = rowIndex;
}

public int getColIndex() {
return colIndex;
}

public void setColIndex(int colIndex) {
this.colIndex = colIndex;


}
/**
* rightClickCount 右键点击次数

* */
private int rightClickCount;

public int getRightClickCount() {
return rightClickCount;
}

public void setRightClickCount(int rightClickCount) {
this.rightClickCount = rightClickCount;
}

}

package com.sf.minesweeper.bean;

public class Own implements Comparable<Own>{
private int times;
private String name;
private String level;


public Own(int times, String name, String level) {
super();
this.times = times;
this.name = name;
this.level = level;
}
public String getLevel() {
return level;
}
public void setLevel(String level) {
this.level = level;
}
public int getTimes() {
return times;
}
public void setTimes(int times) {
this.times = times;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}

public int compareTo(Own arg0) {
// TODO Auto-generated method stub
int i = this.times - arg0.times;
if(i==0){
return this.name.hashCode() - arg0.name.hashCode();
}
return i;
}

}

界面如下:

出现问题及解决办法:

结对伙伴:黄坤

http://www.cnblogs.com/kryst4l 

北京电子科技学院(BESTI)

实     验    报     告

课程:Java程序设计   班级:1353      姓名:王亦可  学号:20135326

成绩:             指导教师:娄嘉鹏      实验日期:

实验密级:         预习程度:             实验时间:

仪器组次:          必修/选修:选修       实验序号:3

实验名称:                敏捷开发与XP实践                           

实验目的与要求:                                                        

完成实验、撰写实验报告,实验报告以博客方式发表在博客园,注意实验报告重点是运行结果,遇到的问题(工具查找,安装,使用,程序的编辑,调试,运行等)、解决办法(空洞的方法如“查网络”、“问同学”、“看书”等一律得0分)以及分析(从中可以得到什么启示,有什么收获,教训等)。报告可以参考范飞龙老师的指导                             

                                                                     

实验仪器:

名称

型号

数量

Pc

 

1

 

 

 

重构:

一、一个完整的重构流程包括:

  1. 从版本控制系统代码库中Check out code
  2. 读懂代码(包括测试代码)
  3. 发现bad smell
  4. Refactoring
  5. 运行所有的Unit Tests
  6. 往代码库中Check in code

二、重构技能

三、何时需要重构

TDD测试:

 四、游戏:扫雷

import static org.junit.Assert.*;

import org.junit.Test;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;

import MyFrame.Constant;
public class testTank {
private int x,y;
private int wid=Constant.WW;
private int hei=Constant.WH;
public int tet(int x, int y) {
this.x = x;
this.y = y;
return 0;
}
public void draw(Graphics g){
Color c=g.getColor();
g.setColor(Color.GRAY);
g.fillRect(x, y, wid, hei);
g.setColor(c);
}
public Rectangle getRect(){
return new Rectangle(x,y,wid,hei);
}

@Test
public void test() {

assertEquals(0,tet(1,1));
}

}

package com.sf.minesweeper.bean;

import javax.swing.JLabel;
/**
* 自定义标签(雷块)
*/
public class MineLabel extends JLabel {

private static final long serialVersionUID = -7271927020145498558L;

/**
* 判断是否是雷

* */
private boolean isMine;
/**
* 判断雷块是否展开

* */
private boolean isExpanded;
/**
* 判断雷块是否是旗子

* */
private boolean isFlag;
/**
* 判断是否是雷且未标上旗子
* */
private boolean isMineAndNotflag;
/**
* count 计算雷块周围的雷数

* */
private int mineCount;
/**
* 雷块所在的行

* */
private int rowIndex;
/**
* 雷块所在的列

* */
private int colIndex;


private int expend=0;

//雷区上的行列坐标
public MineLabel(int rowIndex, int colIndex) {
this.rowIndex = rowIndex;
this.colIndex = colIndex;
}
//一向是对应的一些get和set方法
public boolean isMine() {
return isMine;
}

public void setMine(boolean isMine) {
this.isMine = isMine;
}

public boolean isExpanded() {
return isExpanded;
}

public void setExpanded(boolean isExpanded) {
this.isExpanded = isExpanded;
}

public boolean isFlag() {
return isFlag;
}

public void setFlag(boolean isFlag) {
this.isFlag = isFlag;
}

public int getMineCount() {
return mineCount;
}

public void setMineCount(int mineCount) {
this.mineCount = mineCount;
}

public int getRowIndex() {
return rowIndex;
}

public void setRowIndex(int rowIndex) {
this.rowIndex = rowIndex;
}

public int getColIndex() {
return colIndex;
}

public void setColIndex(int colIndex) {
this.colIndex = colIndex;


}
/**
* rightClickCount 右键点击次数

* */
private int rightClickCount;

public int getRightClickCount() {
return rightClickCount;
}

public void setRightClickCount(int rightClickCount) {
this.rightClickCount = rightClickCount;
}

}

package com.sf.minesweeper.bean;

public class Own implements Comparable<Own>{
private int times;
private String name;
private String level;


public Own(int times, String name, String level) {
super();
this.times = times;
this.name = name;
this.level = level;
}
public String getLevel() {
return level;
}
public void setLevel(String level) {
this.level = level;
}
public int getTimes() {
return times;
}
public void setTimes(int times) {
this.times = times;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}

public int compareTo(Own arg0) {
// TODO Auto-generated method stub
int i = this.times - arg0.times;
if(i==0){
return this.name.hashCode() - arg0.name.hashCode();
}
return i;
}

}

界面如下:

出现问题及解决办法:

结对伙伴:黄坤

http://www.cnblogs.com/kryst4l 

以上是 JAVA第三次实验 的全部内容, 来源链接: utcz.com/z/392216.html

回到顶部