修改Equation,将生成题目字符串答案替换为“?”,删除计算答案部分

main
Teptao 5 months ago
parent 4f09a4c521
commit e464f4a245

@ -1,19 +0,0 @@
1. 55 + 80 - 9 * 89 = 11214
2. 22 + 60 = 82
3. 35 / 5 * 56 / 8 = 49
4. 69 * 60 / 24 / 8 = 21
5. 99 + 80 - 96 - 64 = 19
6. 23 - 2 = 21
7. 92 + 45 = 137
8. 17 * 100 * 97 - 83 = 164817
9. 10 / 3 / 3 * 62 = 62
10. 24 / 6 + 41 - 50 / 10 = 0

@ -26,11 +26,6 @@ public abstract class AbstractProblemGenerator implements IProblemGenerator {
while (newProblems.size() < count) {
Equation candidate = createProblem();
// 检查最终结果是否为负数,如果是则舍弃(小学和初中常见要求)
if (candidate.getResult() < 0) {
continue;
}
String canonicalForm = candidate.toCanonicalString();
// 执行唯一性检查:既不能与历史重复,也不能与本次生成的其他题目重复

@ -98,7 +98,7 @@ public class Application {
handleGenerateProblems(count);
} else {
throw new InvalidInputException(
String.format("无效输入。请输入 %d-%d 之间的数字、'切换为XX' 或 '-1'。",
String.format("请输入小学、初中和高中三个选项中的一个",
MIN_GENERATE_COUNT, MAX_GENERATE_COUNT));
}
} catch (InvalidInputException | IOException | NumberFormatException e) {

@ -12,19 +12,16 @@ public class Equation {
private final List<String> operands; // 使用String以支持如 "sqrt(16)" 的形式
private final List<Operator> operators;
private final int result;
public Equation(List<String> operands, List<Operator> operators) {
this.operands = new ArrayList<>(operands);
this.operators = new ArrayList<>(operators);
this.result = calculate();
}
// 为了方便,提供一个只接受整数操作数的构造函数
public Equation(List<Integer> intOperands, List<Operator> operators, boolean isSimple) {
this.operands = intOperands.stream().map(String::valueOf).collect(Collectors.toList());
this.operators = new ArrayList<>(operators);
this.result = calculate();
}
public List<String> getOperands() {
@ -35,9 +32,6 @@ public class Equation {
return Collections.unmodifiableList(operators);
}
public int getResult() {
return result;
}
/**
*
@ -75,7 +69,7 @@ public class Equation {
sb.append(" ").append(operators.get(i).getSymbol()).append(" ");
sb.append(operands.get(i + 1));
}
sb.append(" = ").append(result);
sb.append(" = ").append("?");
return sb.toString();
}

Loading…
Cancel
Save