You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
MathLearningApp/src/main/java/mathlearning/service/QuestionGenerator/PrimaryGenerator.java

23 lines
563 B

package mathlearning.service.QuestionGenerator;
public class PrimaryGenerator extends QuestionGenerator{
public PrimaryGenerator() {
super("小学");
}
@Override
public String generateQuestion() {
int operandCount = random.nextInt(4) + 2;
// 生成操作数
int[] operands = new int[operandCount];
for (int i = 0; i < operandCount; i++) {
operands[i] = random.nextInt(100) + 1; // 1-100
}
String question = preForOper(operands);
return addParen(question);
}
}