mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package cn.hutool.captcha.generator;
|
||||
|
||||
import cn.hutool.core.math.Calculator;
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -59,20 +60,8 @@ public class MathGenerator implements CodeGenerator {
|
||||
return false;
|
||||
}
|
||||
|
||||
final int a = Integer.parseInt(StrUtil.sub(code, 0, this.numberLength).trim());
|
||||
final char operator = code.charAt(this.numberLength);
|
||||
final int b = Integer.parseInt(StrUtil.sub(code, this.numberLength + 1, this.numberLength + 1 + this.numberLength).trim());
|
||||
|
||||
switch (operator) {
|
||||
case '+':
|
||||
return (a + b) == result;
|
||||
case '-':
|
||||
return (a - b) == result;
|
||||
case '*':
|
||||
return (a * b) == result;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
final int calculateResult = (int) Calculator.conversion(code);
|
||||
return result == calculateResult;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user