成员: 林 钊 -- 201421123105 吴世荣 -- 201421123119 王坤彬 -- 201421123108
coding地址:https://coding.net/u/linzhao/p/UnitTest/git
需求分析:
1.整数加减乘除的测试;
2.分数加减乘除的测试;
3.最大公约数测试;
4.判断真分数测试;
计算模块:
public
int
gcd(
int
a,
int
b)
//公约数
{
if
(a == 0)
{
return
b;
}
else
if
(b == 0)
{
return
a;
}
else
{
return
gcd(b % a, a);
}
}
public
int
Calculate(
int
type,
int
op1,
int
op2)
//整数四则运算
{
int
result = 0;
if
(type == 1)
{
result = op1 + op2;
}
if
(type == 2)
{
result = op1 - op2;
}
if
(type == 3)
{
result = op1 * op2;
}
if
(type == 4)
{
result = op1 / op2;
}
return
result;
}
public
string
CalculateFengsu(
int
up1,
int
down1,
int
up2,
int
down2,
int
type)
//分数四则运算
{
string
result =
""
;
if
(type == 1)
{
up1 = (up1 * down2 + up2 * down1);
down1 = down1 * down2;
up2 = gcd(up1, down1);
up1 = up1 / up2;
down1 = down1 / up2;
result = up1.ToString() +
"/"
+ down1.ToString();
return
result;
}
if
(type == 2)
{
up1 = (up1 * down2 - up2 * down1);
down1 = down1 * down2;
up2 = gcd(up1, down1);
up1 = up1 / up2;
down1 = down1 / up2;
result = up1.ToString() +
"/"
+ down1.ToString();
return
result;
}
if
(type == 3)
{
up1 = up1 * up2;
down1 = down1 * down2;
up2 = gcd(up1, down1);
up1 = up1 / up2;
down1 = down1 / up2;
result = up1.ToString() +
"/"
+ down1.ToString();
return
result;
}
if
(type == 4)
{
up1 = up1 * down2;
down1 = down1 * up2;
up2 = gcd(up1, down1);
up1 = up1 / up2;
down1 = down1 / up2;
result = up1.ToString() +
"/"
+ down1.ToString();
return
result;
}
return
result;
}
public
string
CalculateZfengsu(
int
up1,
int
down1)
//判断及生成真分数
{
string
result =
"true"
;
int
mid = 0;
if
(up1 > down1)
{
mid = down1;
down1 = up1;
up1 = mid;
result = up1.ToString() +
"/"
+ down1.ToString();
return
result;
}
if
(up1 == down1)
{
down1 += 3;
result = up1.ToString() +
"/"
+ down1.ToString();
return
result;
}
return
result;
}
一、公约数测试:
gcd(
int
a,
int
b)
二、整数加减乘除测试:
Calculate(
int
type,
int
op1,
int
op2) //其中type为运算类型,op1,op2为整数。
三、分数四则运算:
CalculateFengsu(
int
up1,
int
down1,
int
up2,
int
down2,
int
type) //其中up1,up2为分子,down1,down2为分母,type为运算类型。
四、判断真分数:
CalculateZfengsu(
int
up1,
int
down1) //up1,down1分别为分子分母。
五、代码覆盖率:
六、小结:
这是结对编程的第二次作业,说实话一开始不知道怎么做,都是在网上各种搜索资料,再向其他小组请教,接着几个人慢慢摸索,最后一起做出来了,成就感满满~
七、Git 版本控制系统保存工作文件:
八、PSP表格:
PSP2.1 |
Personal Software Process Stages |
Time Senior Student |
Time |
Planning |
计划 |
0.5h |
0.5h |
· Estimate |
估计这个任务需要多少时间 |
2h |
2.5h |
Development |
开发 |
1.5h |
1h |
· Analysis |
需求分析 (包括学习新技术) |
20min |
10min |
· Design Spec |
生成设计文档 |
10min |
6min |
· Design Review |
设计复审 |
10min |
16min |
· Coding Standard |
代码规范 |
5min |
3min |
· Design |
具体设计 |
20min |
12min |
· Coding |
具体编码 |
40min |
21min |
· Code Review |
代码复审 |
15min |
9min |
· Test |
测试(自我测试,修改代码,提交修改) |
15min |
21min |
Reporting |
报告 |
5min |
6min |
· |
测试报告 |
5min |
2min |
· |
计算工作量 |
5min |
1min |
· |
提出过程改进计划 |
10min |
3min |