|
|
|
|
@ -205,21 +205,25 @@ public class ConsoleUI {
|
|
|
|
|
* @param currentLevel 当前选择的难度级别。
|
|
|
|
|
*/
|
|
|
|
|
private void handleGeneration(User user, Level currentLevel) {
|
|
|
|
|
printHeader("生成 " + currentLevel.getChineseName() + " 题目");
|
|
|
|
|
System.out.print("请输入生成题目数量 (10-30,输入 0 返回主菜单): ");
|
|
|
|
|
try {
|
|
|
|
|
int count = Integer.parseInt(scanner.nextLine().trim());
|
|
|
|
|
if (count == 0) {
|
|
|
|
|
System.out.println("已取消生成,返回主菜单。");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (count >= 10 && count <= 30) {
|
|
|
|
|
paperService.createAndSavePaper(user, count, currentLevel);
|
|
|
|
|
} else {
|
|
|
|
|
System.out.println("输入无效,题目数量必须在 10 到 30 之间。");
|
|
|
|
|
while (true) {
|
|
|
|
|
printHeader("生成 " + currentLevel.getChineseName() + " 题目");
|
|
|
|
|
System.out.print("请输入生成题目数量 (10-30,输入 0 返回主菜单): ");
|
|
|
|
|
String input = scanner.nextLine().trim();
|
|
|
|
|
try {
|
|
|
|
|
int count = Integer.parseInt(input);
|
|
|
|
|
if (count == 0) {
|
|
|
|
|
System.out.println("已取消生成,返回主菜单。");
|
|
|
|
|
break; // 退出循环,返回主菜单
|
|
|
|
|
}
|
|
|
|
|
if (count >= 10 && count <= 30) {
|
|
|
|
|
paperService.createAndSavePaper(user, count, currentLevel);
|
|
|
|
|
break; // 成功生成,退出循环,返回主菜单
|
|
|
|
|
} else {
|
|
|
|
|
System.out.println("无效输入,题目数量必须在 10 到 30 之间。请重新输入。");
|
|
|
|
|
}
|
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
|
System.out.println("无效输入,请输入一个有效的数字。请重新输入。");
|
|
|
|
|
}
|
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
|
System.out.println("输入无效,请输入一个有效的数字。");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
|