0422 发现( 数学口袋精灵)bug
团队博客地址:
甘佳萍:http://www.cnblogs.com/gjpg/
李鹏飞:http://www.cnblogs.com/l549023320/
赵创佳:http://www.cnblogs.com/7763255qw/
口袋精灵,
bug发现:
1、在运行过程中会出现程序闪退。
2、运行过程中音乐没办法关闭。
3、不能退出。
单元测试代码如下:
package com.example.mathsapp;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;
public class KuohaoCalc {
; // 记录单个运算数据的长度
static DecimalFormat decimal = new DecimalFormat("#.##");
// 判断是否有带括号的运算字符串存在
public String interceResult(String str) {
String finalresult;
String result = str;
char[] numberString = str.toCharArray();
; // 记录“(”的实际数量
; // 记录“)”的实际数量
; i < numberString.length; i++) {
if ('(' == numberString[i]) {
// 记录最后一个正括号的位置
IndexStart = i;
}
if (')' == numberString[i]) {
// 记录反括号的最初始下标的位置
EndStart = i;
// 截取最里面一个括号里的运算字符串
result = result.substring(IndexStart + , EndStart);
// 截取括号的运算字符串进行运算,生成新的运算字符串
result = str.substring(, IndexStart)
+ interceptOperation(result, '*', '÷')
+ str.substring(EndStart + , str.length());
// 回调执行,其它小括号的运算字符串
return interceResult(result);
}
)
)
break;
}
// 不存在括号了,再进行混合运算
result = interceptOperation(str, '*', '÷');
double res=Double.parseDouble(result);
decimal.setRoundingMode(RoundingMode.HALF_UP);//四舍五入
finalresult=String.valueOf(decimal.format(res));
return finalresult;
}
// 不带括号的四则运算
private static String interceptOperation(String operationNumber, char a,
char b) {
String mess = operationNumber;
char[] stringOperation = mess.toCharArray();
// 循环遍历运算字符串,并做相应的运算
; i < stringOperation.length; i++) {
// 判断运算符所在的索引
if (stringOperation[i] == a || stringOperation[i] == b) {
) {
// 运算符前的第一个数
, i));
// 记录第一个数据的长度
int frontPosition = intercePosition;
// 运算符前的第二个数
,
stringOperation.length));
// 记录第二个数据的长度
int backPosition = intercePosition;
// 算完乘除,将结果替换到原来运算的位置,得到新的运算字符串
String IndexMess = mess.substring(, i - frontPosition + );
String IndexResult = "";
// 判断是否运算到最后的结果了
&& IndexMess.indexOf(
&& IndexMess.indexOf(
&& IndexMess.lastIndexOf()
IndexMess = "";
if (IndexMess != "")
IndexResult = IndexMess.lastIndexOf('-') == IndexMess
.length() - ? IndexMess.substring(, i
- frontPosition) : IndexMess;
// 组装新的运算字符串
mess = IndexResult// mess.substring(0,i-frontPosition+1)
+ reslutString("" + stringOperation[i], num1, num2)
+ mess.substring(i + backPosition + );
// 0.111/1212/2/2/2/2/2/2/2
&& mess.indexOf(
&& mess.indexOf(
&& mess.indexOf() {
break;
}
// 回调,继续运算
return interceptOperation(mess, a, b);// 1+7-5+89/3+4-6*8/2+4-6
} else
continue;
}
) {
// 递归出口,判断是否还有运算字符串在
|| mess.indexOf()
return interceptOperation(mess, '+', '-');
break;
}
}
return mess;
}
// 截取第二个数
private static double interceptNumEnd(String str) {
;
;
char[] stringOperation = str.toCharArray();
boolean ispas = false; // 记录是否为负数
; i < stringOperation.length; i++) {
switch (stringOperation[i]) {
case '*':
case '÷':
case '+':
case '-':
InrerceIndex = i;
) // 判断该数是否为负数
ispas = true;
break;
default:
break;
}
if (ispas)
break;
}
// 判断此数据是否在运算字符串的最后一位
) {
a = Double.parseDouble(str);
intercePosition = str.length();
if (ispas)
intercePosition++;
} else {
a = Double.parseDouble(str.substring(, InrerceIndex));
// 记录数据的真实长度
intercePosition = str.substring(, InrerceIndex).length();
}
return a;
}
// 截取第一个数
private static double interceptNumIndex(String str) {
; // 记录数据
; // 记录运算符的位置
boolean temp = false; // 记录数据前运算符的状态
char[] stringOperation = str.toCharArray();
; i >= ; i--) {
switch (stringOperation[i]) {
case '*':
case '÷':
case '+':
case '-':
InrerceIndex = i;
temp = true;
break;
default:
break;
}
if (temp)
break;
}
// 判断此数据是否在运算字符串的第一位
) {
a = Double.parseDouble(str);
intercePosition = str.length();
// if(temp)
// intercePosition++;
} else {
a = Double.parseDouble(str.substring(InrerceIndex, str.length()));
// 记录数据的真实长度
intercePosition = str.substring(InrerceIndex, str.length())
.length();
}
return a;
}
// 计算结果
private static double reslutString(String operation, double num1,
double num2) {
;
if (operation.equals("*"))
sumResult = num1 * num2;
if (operation.equals("-"))
sumResult = num1 - num2;
if (operation.equals("÷"))
sumResult = num1 / num2;
if (operation.equals("+"))
sumResult = num1 + num2;
return sumResult;
}
}
测试结果:


由于时间的能力有限,暂时没法修复bug;
0422 发现( 数学口袋精灵)bug的更多相关文章
- 0422 寻找数学口袋精灵BUG
首先要部署这个app项目就是第一步: 一.前提下载并安装JDK 在线图解:手把手教你安装JDK http://www.lvtao.net/server/windows-setup-jdk.h ...
- 0422数学口袋精灵bug发现
团队成员的博客园地址: 蔡彩虹:http://home.cnblogs.com/u/caicaihong/ 曾治业:http://www.cnblogs.com/zzy999/ 蓝叶:http://w ...
- 0422“数学口袋精灵”BUG发现
团队成员的博客园地址: 曾治业:http://www.cnblogs.com/zzy999/ 蔡彩虹:http://www.cnblogs.com/caicaihong/ 蓝叶:http://www. ...
- "数学口袋精灵"bug的发现
团队成员的博客园地址: 曾治业:http://www.cnblogs.com/zzy999/ 陈焕恳:http://www.cnblogs.com/4249ken/ 蓝叶:http://www.cnb ...
- "数学口袋精灵"bug
首先要部署这个app项目就是第一步: 一.前提下载并安装JDK 在线图解:手把手教你安装JDK http://www.lvtao.net/server/windows-setup-jdk.h ...
- "数学口袋精灵"bug的发现及单元测试
1.项目内容: 团队项目:二次开发 至此,我们有了初步的与人合作经验,接下来投入到更大的团队中去. 也具备了一定的个人能力,能将自己的代码进行测试.接下来尝试在别人已有的基础上进行开发. 上一界51冯 ...
- 找"数学口袋精灵"bug
团队成员的博客园地址: 刘森松:http://home.cnblogs.com/u/lssh/ 郭志豪:http://home.cnblogs.com/u/gzh13692021053/ 谭宇森:ht ...
- "数学口袋精灵"bug(团队)
团队名:MY-HR 成员: 学号 博客园 团队贡献分 丘惠敏(组长) 201406114203 http://www.cnblogs.com/qiuhuimin/ 5 郭明茵 201406114204 ...
- 0422 数学口袋精灵app
首先要部署这个app项目就是第一步: 一.前提下载并安装JDK 在线图解:手把手教你安装JDK http://www.lvtao.net/server/windows-setup-jdk.h ...
- 数学口袋精灵感受与BUG
232朱杰 http://www.cnblogs.com/alfredzhu https://github.com/alfredzhu/ 组长,团队 230蔡京航 http://www.cnblogs ...
随机推荐
- 解决 The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path
到 http://tomcat.heanet.ie/native/ 下载最新的tcnative-1.dll放到相应目录即可,我目前下载的是 http://tomcat.heanet.ie/native ...
- nodejs - 如何完全更新
Nodejs可以毫不犹豫地说一个版本狂魔,时不时就发布一个版本,而且还一直没有一个1.0版本,好囧呀,对于我们这些有强迫症的人来说,的确不是好事. 下面我就说一下Nodejs中常见的更新方式. 1. ...
- fio terse输出详解
fio, the flexible IO tester, is a very useful tool for benchmarking IO performance. It has an option ...
- IOS从一个APP跳到另一个APP
以下为跳转到大众点评APP代码如下: NSString *requestUrlString = @"dianping://shopinfo?id=1000"; NSURL *req ...
- Red Hat dhclient
如果你是通过dhcp动态获取ip进行上网,我们一般情况下需要对/etc/sysconfig/network-scripts目录下对应的网卡配置进行修改,将BOOTPROTO改为dhcp.更简单的方法是 ...
- [GraphQL] Use GraphQLNonNull for Required Fields
While certain fields in a GraphQL Schema can be optional, there are some fields or arguments that ar ...
- 更新iOS Distribution Certificates
1. 鑰匙圈存取 -> 憑證輔助程式 -> 從憑證授權要求憑證 email:xxx@xxxx 得到 Blia_20140129.certSigningReques 2.進入開發帳號 憑證 ...
- JVM 参数翻译汉化解释
博客搬家,新地址:http://www.zicheng.net/article/38.htm Behavioral Options(行为参数) Option and Default Value Des ...
- Eplan 2D安装版布局,部件、端子竖放
部件竖放,不是通过变量的选择实现,而是通过设置实现的,具体设置在: 选项-设置-用户-2D安装板布局: 部件方向-更改为 垂直 部件放置-旋转角度-更改为90° 这样在连续放置部件的时候就变为竖放了, ...
- iOS 模拟器键盘弹出以及中文输入
1.虚拟键盘的弹出与收起切换: 快捷键:command+shift+K 2.中文输入: Xcode 菜单项 --> Product --> Scheme --> Edit Schem ...