结对成员:

需求分析

需增加乘方开根号功能
重复式子的审查
括号运算符

思维导图

核心代码

package test;
import java.util.*;
public class Calc{
public static void main(String args[]){
ArrayList question=new ArrayList();
System.out.println("请输入要计算的式子个数:");
Scanner sc=new Scanner(System.in);
int count=sc.nextInt();
System.out.println("请输入你要求解的式子:");
for(int i=0;i<count;i++){
sc=new Scanner(System.in);
question.add(sc.nextLine());
}
for(int i=0;i<count;i++){
System.out.print(question.get(i)+"=");
CalcFunction calc = new CalcFunction();;
calc.calc(question.get(i));
}
}
}
public void involution(String s) //乘方
{
String[] str=s.split("\^");
if(str[0].indexOf("/")>-1 || str[1].indexOf("/")>-1)//分数
{
String[] str1=str[0].split("\/");
String[] str2=str[1].split("\/");
if(Integer.parseInt(str1[1]) != 0)//分母不为零
{
int a=Integer.parseInt(str1[0]);
int b=Integer.parseInt(str1[1]);
int c=Integer.parseInt(str[1]);
double m=Math.pow(a, c);
double n=Math.pow(b, c);
result =simplefraction((int)m,(int)n);
}else{
throw new IllegalArgumentException("Divisor cannot be zero!");//除数为零时抛出异常
}
}
else{
if( Integer.parseInt(str[0])<1000&&Integer.parseInt(str[1])<1000&&Integer.parseInt(str[0])>-1000&&Integer.parseInt(str[1])>-1000)
{int a=Integer.parseInt(str[0]);
int b=Integer.parseInt(str[1]);
result = Math.pow(a,b) +"";
}
else{
throw new IllegalArgumentException("overrun!");//数值范围超出时抛出异常
}
}
}
public void sqrt(String s) //开根号
{ int sq=s.indexOf("!");
String str=s.substring(sq);
if(Integer.parseInt(str)>-1)
{
double a=Integer.parseInt(str);
result = Math.sqrt(a) +"";
}
else{
throw new IllegalArgumentException("overrun!");//数值范围超出时抛出异常
}
}

运行截图

码云提交

psp

PSP2.1 个人开发流程 预估耗费时间(分钟) 实际耗费时间(分钟)
Planning 计划 30 50
Estimate 明确需求和其他相关因素,估计每个阶段的时间成本 15 10
Development 开发 150 200
Analysis 需求分析 (包括学习新技术) 20 30
Design Spec 生成设计文档 20 20
Design Review 设计复审 10 10
Coding Standard 代码规范 10 10
Design 具体设计 30 30
Coding 具体编码 60 80
Code Review 代码复审 10 20
Test 测试(自我测试,修改代码,提交修改) 15 30
Reporting 报告 30 40
测试报告 10 10
计算工作量 10 5
并提出过程改进计划 10 15

合照

总结

这次结对编程收获颇丰但由于时间和水平的原因,还有许多功能并未实现,希望在以后的作业和项目中有更大的进步o.o

posted on 2018-03-25 21:47  网一16号  阅读(131)  评论(1编辑  收藏  举报