20162304 阶段编程四则运算(挑战出题)
2017-06-04 22:58
253 查看
20162304 阶段编程四则运算(挑战出题)
结对伙伴:20162318需求分析
要能指定生成题目的数量每次生成的题目不能有重复
要能指定题目包含的运算符数量
通过命令行参数形式指定题目要求
输出题目到文件,一行一个题目
设计思路
先进行中缀转后缀对后缀进行排序
若后缀相同,则进行答案判断
UML类图
实现过程中的关键代码解释
public class Sort { private String result, str, result2, result3; // 排序(数字大小排序,非数字位置不变) public String sorting(String s) { String p = s.trim(); String[] str = p.split(" "); List<String> list = new ArrayList<String>(); for (int i = 0; i < str.length; i++) { //判断是不是数字 if (isNumeric(str[i])) { list.add(str[i]); } } //排大小 String[] strings = new String[list.size()]; for (int i = 0; i < list.size(); i++) { strings[i] = list.get(i); } for (int x = 0; x < strings.length - 1; x++) { for (int y = x + 1; y < strings.length; y++) { int s1 = Integer.parseInt(strings[x]); int s2 = Integer.parseInt(strings[y]); if (s1 >= s2) { String temp = strings[x]; strings[x] = strings[y]; strings[y] = temp; } } } int j = 0; for (int i = 0; i < str.length; i++) { //判断是数字还是符号 if (isNumeric(str[i])) { str[i] = strings[j]; j++; } } String c = " "; for (int i = 0; i < str.length; i++) c += (str[i] + " "); return c; } //判断是否为数字 public boolean isNumeric(String str) { Pattern pattern = Pattern.compile("[0-9]*"); Matcher isNum = pattern.matcher(str); if (!isNum.matches()) { return false; } return true; } }
l1 = title.promber3(i + 1, 9, 4, 1);//生成题目 result1 = con.storage(l1);//中转后 result3 = eva.calculate(result1);//计算当前 result2 = sort.sorting(result1);//排序 if (list.size() != 0) { for (int w = 0; w < list.size(); w++) { //判断排序后的式子是否相同 if (result2.equals(list.get(w))) { result4 = eva.calculate(list2.get(w));//计算排序后的式子相同的答案 if (result3.equals(result4)) { x = 1; s --; break; } } } } if (x == 0) { list.add(result2);//排序后的题目 list1.add(l1);//原题目 list2.add(result1);//中转后 }
测试方法
用老师给的程序进行测试。运行过程截图
代码托管地址
遇到的困难及解决方法
遇到的困难就是运行的时候可能会出现崩溃的情况,不过在运行几次就好了。对结对的小伙伴做出评价
我的结对伙伴比较给力,上星期就已经实现了本周的部分要求,然后要说有什么不足的话,希望以后我俩可以更默契一点吧。给我的结对伙伴打分55分,在整个结对编程的过程中,泰毓同学教会了我很多东西,IDEA使用的一些小技巧啊啥的等等,总之跟感谢他。
PSP
PSP2.1 | Personal Software Process Stages | 预估耗时(小时) | 实际耗时(小时) |
---|---|---|---|
Planning | 计划 | 0.5 | 0.5 |
· Estimate | · 估计这个任务需要多少时间 | 0.5 | 0.5 |
Development | 开发 | 2.4 | 3 |
· Analysis | · 需求分析 (包括学习新技术) | 0.3 | 0.2 |
· Design Spec | · 生成设计文档 | 0.1 | 0.2 |
· Design Review | · 设计复审 (和同事审核设计文档) | 0.5 | 1 |
· Coding Standard | · 代码规范 (为目前的开发制定合适的规范) | 0.2 | 0.2 |
· Design | · 具体设计 | 0.2 | 0.2 |
· Coding | · 具体编码 | 1 | 0.2 |
· Code Review | · 代码复审 | 0.5 | 1 |
· Test | · 测试(自我测试,修改代码,提交修改) | 5 | 8 |
Reporting | 报告 | 1.7 | 2.5 |
· Test Report | · 测试报告 | 1 | 0.5 |
· Size Measurement | · 计算工作量 | 0.5 | 0.1 |
· Postmortem & Process Improvement Plan | · 事后总结, 并提出过程改进计划 | 0.2 | 0.5 |
总计 | 4.6 | 6 |
相关文章推荐
- 阶段编程四则运算(挑战出题)
- Java结对编程之挑战出题
- 20162312Java结对编程之挑战出题
- 四则运算(挑战出题)解答之轮子哥版-1
- 20162306陈是奇 四则运算结对编程(挑战出题)总结
- (挑战编程_9_2)Playing with Wheels
- virtual hust 2013.6.21 NEFU 挑战编程----数论 D - Factovisors
- virtual hust 2013.6.21 NEFU 挑战编程----数论 F - Smith Numbers
- Java并发编程的挑战
- 编程挑战题目--倒水
- 大二上学期的一个阶段的编程锻炼
- 挑战面试编程:字符串匹配的双重递归式写法
- 编程挑战之倒水——问题在哪儿呢
- Qt下的OpenGL 编程(12)阶段学习总结
- 360公司招聘编程,可以挑战一下哦~~
- 编程挑战:字符串的完美度
- csdn高校编程挑战数字填充
- 51nod 编程挑战
- 编程挑战之三角形内切圆与外接圆源码
- 编程的三个阶段