|
|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
package com.ybw.mathapp.service;
|
|
|
|
|
|
|
|
|
|
import static com.ybw.mathapp.service.AdvancedCaculate.isNumeric;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
@ -78,26 +80,6 @@ public class PrimarySchoolGenerator implements QuestionGenerator {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断给定字符串是否为数字。
|
|
|
|
|
*
|
|
|
|
|
* <p>该方法检查字符串是否可以转换为数字格式。
|
|
|
|
|
*
|
|
|
|
|
* @param str 待检查的字符串
|
|
|
|
|
* @return 如果字符串是数字则返回true,否则返回false
|
|
|
|
|
*/
|
|
|
|
|
public static boolean isNumeric(String str) {
|
|
|
|
|
if (str == null || str.isEmpty()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
Double.parseDouble(str);
|
|
|
|
|
return true;
|
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生成基本的四则运算表达式部分。
|
|
|
|
|
*
|
|
|
|
|
|