标签:for 网上 下载 cas ret package 函数 方便 osc
任务一,Install Junit(4.12), Hamcrest(1.3) with Eclipse
首先在网上下载Junit和Hamcrest的jar文件,Right click on the project root directory - > build path - > configure build path - > library the junit. Jar, hamcrest. Jar added
任务二,Install Eclemma with Eclipse
在myeclipse顶部菜单栏中 help->install from catalog,在搜索栏中输入Eclemma,点击安装,一步步按照提示,即可完成安装
任务三,Write a java program for the triangle problem and test the program with Junit.
a) Description of triangle problem:
Function triangle takes three integers a,b,c which are length of triangle sides; calculates whether the triangle is equilateral, isosceles, or scalene.
progran:
package hw1;
public class exp {
public int trian(int a,int b,int c){
if((a==b)&&(a==c)&&(b==c)){ //等边三角形
return 0;
}
else if((a != b)&&(a!=c)&&(b!=c)){ //不等边三角形
return 1;
}
else{
return 2; //等腰三角形
}
}
}
b)Using junit test
测试正确,使用junit进行程序测试,会发现非常方便,很容易找到哪里出错。
标签:for 网上 下载 cas ret package 函数 方便 osc
原文地址:http://www.cnblogs.com/luhe-1378228170/p/6539131.html