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.
34 lines
1.0 KiB
34 lines
1.0 KiB
import java.util.Random;
|
|
|
|
public class SeniorQuestionGenerator extends AbstractQuestionGenerator {
|
|
private static final String[] TRIG_FUNCTIONS = {"sin", "cos", "tan"};
|
|
private static final String[] OPERATORS = {"+", "-"};
|
|
|
|
@Override
|
|
public String generateQuestion(int operandCount, Random random) {
|
|
// 确保至少有一个三角函数
|
|
StringBuilder question = new StringBuilder();
|
|
String trigFunction = TRIG_FUNCTIONS[random.nextInt(TRIG_FUNCTIONS.length)];
|
|
int angle = random.nextInt(360);
|
|
|
|
question.append(trigFunction).append("(").append(angle).append("°)");
|
|
|
|
// 添加其他操作数
|
|
for (int i = 1; i < operandCount; i++) {
|
|
String operator = OPERATORS[random.nextInt(OPERATORS.length)];
|
|
int number = random.nextInt(MAX_OPERAND) + MIN_OPERAND;
|
|
question.append(" ").append(operator).append(" ").append(number);
|
|
}
|
|
|
|
return question.toString();
|
|
}
|
|
|
|
@Override
|
|
public String getQuestionType() {
|
|
return "高中";
|
|
}
|
|
}
|
|
|
|
|
|
|