diff --git a/doc/README.md b/doc/README.md
index 58192c2..e9e261d 100644
--- a/doc/README.md
+++ b/doc/README.md
@@ -8,26 +8,26 @@
- **文件保存**:题目按“年-月-日-时-分-秒.txt”保存到用户专属文件夹。
## 2. 预设账号
-| 学段 | 用户名 | 密码 |
-|--------|------|------|
-| 小学 | 张三 1 | 123 |
-| 小学 | 张三 2 | 123 |
-| 小学 | 张三 3 | 123 |
-| 初中 | 李四 1 | 123 |
-| 初中 | 李四 2 | 123 |
-| 初中 | 李四 3 | 123 |
-| 高中 | 王五 1 | 123 |
-| 高中 | 王五 2 | 123 |
-| 高中 | 王五 3 | 123 |
+| 学段 | 用户名 | 密码 |
+|--------|-----|------|
+| 小学 | 张三1 | 123 |
+| 小学 | 张三2 | 123 |
+| 小学 | 张三3 | 123 |
+| 初中 | 李四1 | 123 |
+| 初中 | 李四2 | 123 |
+| 初中 | 李四3 | 123 |
+| 高中 | 王五1 | 123 |
+| 高中 | 王五2 | 123 |
+| 高中 | 王五3 | 123 |
## 3. 使用步骤
1. **运行程序**:执行`com.mathpaper.main.Main`类的`main`方法。
-2. **登录**:输入“用户名 密码”(如“张三 1 123”),登录成功后显示当前学段。
+2. **登录**:输入“用户名 密码”(如“张三1 123”),登录成功后显示当前学段。
3. **生成题目**:输入10-30的数字,程序自动生成并保存题目。
4. **切换学段**:输入“切换为初中”(示例),切换后可生成对应学段题目。
5. **退出登录**:输入-1,返回登录界面。
## 4. 注意事项
-- 题目数量仅支持10-30,输入其他数字(除-1外)会提示重试。
-- 生成的题目保存在项目根目录`generated_papers`下的用户文件夹中,请勿手动删除。
+- 题目数量仅支持10-30,输入其他数字(除-1外)会退出登录。
+- 生成的题目保存在项目根目录`generated_papers`下的用户文件夹中。
- 切换学段时需严格按照“切换为小学/初中/高中”格式输入,否则提示无效。
\ No newline at end of file
diff --git a/src/.idea/.gitignore b/src/.idea/.gitignore
new file mode 100644
index 0000000..7d05e99
--- /dev/null
+++ b/src/.idea/.gitignore
@@ -0,0 +1,10 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
+# 依赖于环境的 Maven 主目录路径
+/mavenHomeManager.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/src/.idea/misc.xml b/src/.idea/misc.xml
new file mode 100644
index 0000000..03f397c
--- /dev/null
+++ b/src/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/.idea/modules.xml b/src/.idea/modules.xml
new file mode 100644
index 0000000..4cbff6e
--- /dev/null
+++ b/src/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/.idea/.gitignore b/src/com/.idea/.gitignore
new file mode 100644
index 0000000..7d05e99
--- /dev/null
+++ b/src/com/.idea/.gitignore
@@ -0,0 +1,10 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
+# 依赖于环境的 Maven 主目录路径
+/mavenHomeManager.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/src/com/.idea/misc.xml b/src/com/.idea/misc.xml
new file mode 100644
index 0000000..03f397c
--- /dev/null
+++ b/src/com/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/.idea/modules.xml b/src/com/.idea/modules.xml
new file mode 100644
index 0000000..2c632c8
--- /dev/null
+++ b/src/com/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/com.iml b/src/com/com.iml
new file mode 100644
index 0000000..787f398
--- /dev/null
+++ b/src/com/com.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/mathpaper/main/Main.java b/src/com/mathpaper/main/Main.java
index 25f7d1f..3d5d091 100644
--- a/src/com/mathpaper/main/Main.java
+++ b/src/com/mathpaper/main/Main.java
@@ -1,3 +1,4 @@
+// mathpaper/main/Main.java
package com.mathpaper.main;
import com.mathpaper.user.AccountManager;
@@ -24,7 +25,7 @@ public class Main {
String currentType = AccountManager.getAccountType(username);
while (true) {
// 提示信息:始终使用当前有效的 currentType(无效切换后不变)
- System.out.print("\n准备生成" + currentType + "数学题目,请输入生成题目数量(10-30,输入-1退出当前用户):");
+ System.out.print("\n准备生成" + currentType + "数学题目,请输入生成题目数量(10-30,输入-1将退出当前用户,重新登录):");
String input = SCANNER.nextLine().trim();
// 处理学段切换:传入当前学段,确保无效时保留原学段
@@ -50,11 +51,6 @@ public class Main {
List questions = generator.generate(count, username);
FILE_HANDLER.saveQuestions(username, questions);
- // 4. 继续操作提示
- System.out.print("是否继续生成" + currentType + "题目?(输入“是”继续,其他返回主页):");
- if (!SCANNER.nextLine().trim().equals("是")) {
- System.out.println("返回主页,可重新输入数量或切换学段...");
- }
}
}
}
diff --git a/src/com/mathpaper/question/AbstractQuestionGenerator.java b/src/com/mathpaper/question/AbstractQuestionGenerator.java
new file mode 100644
index 0000000..35c5794
--- /dev/null
+++ b/src/com/mathpaper/question/AbstractQuestionGenerator.java
@@ -0,0 +1,22 @@
+package com.mathpaper.question;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class AbstractQuestionGenerator implements QuestionGenerator {
+ protected final QuestionChecker checker = new QuestionChecker();
+
+ @Override
+ public List generate(int count, String username) {
+ List questions = new ArrayList<>();
+ while (questions.size() < count) {
+ String expr = generateSingle();
+ if (!checker.isDuplicate(username, expr)) {
+ questions.add((questions.size() + 1) + ". " + expr + " = ");
+ }
+ }
+ return questions;
+ }
+
+ protected abstract String generateSingle();
+}
\ No newline at end of file
diff --git a/src/com/mathpaper/question/JuniorQuestionGenerator.java b/src/com/mathpaper/question/JuniorQuestionGenerator.java
index baaedf4..4290291 100644
--- a/src/com/mathpaper/question/JuniorQuestionGenerator.java
+++ b/src/com/mathpaper/question/JuniorQuestionGenerator.java
@@ -1,28 +1,13 @@
package com.mathpaper.question;
import com.mathpaper.util.Utils;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Random;
-public class JuniorQuestionGenerator implements QuestionGenerator {
- private final QuestionChecker checker = new QuestionChecker();
+public class JuniorQuestionGenerator extends AbstractQuestionGenerator {
private final Random RANDOM = new Random();
@Override
- public List generate(int count, String username) {
- List questions = new ArrayList<>();
- while (questions.size() < count) {
- String expr = generateSingle();
- if (!checker.isDuplicate(username, expr)) {
- questions.add((questions.size() + 1) + ". " + expr + " = ");
- }
- }
- return questions;
- }
-
- // 生成一道初中题(确保含平方/开根号)
- private String generateSingle() {
+ protected String generateSingle() {
String expr = "";
do {
int operandCount = Utils.getOperandCount();
diff --git a/src/com/mathpaper/question/PrimaryQuestionGenerator.java b/src/com/mathpaper/question/PrimaryQuestionGenerator.java
index 804f7f4..cdfe5a7 100644
--- a/src/com/mathpaper/question/PrimaryQuestionGenerator.java
+++ b/src/com/mathpaper/question/PrimaryQuestionGenerator.java
@@ -1,28 +1,12 @@
+// 修改后的PrimaryQuestionGenerator.java
package com.mathpaper.question;
import com.mathpaper.util.Utils;
-import java.util.ArrayList;
-import java.util.List;
-public class PrimaryQuestionGenerator implements QuestionGenerator {
- private final QuestionChecker checker = new QuestionChecker();
+public class PrimaryQuestionGenerator extends AbstractQuestionGenerator {
@Override
- public List generate(int count, String username) {
- List questions = new ArrayList<>();
- // 生成不重复题目
- while (questions.size() < count) {
- String expr = generateSingle();
- if (!checker.isDuplicate(username, expr)) {
- // 添加题号和等号(如“1. 2 + 3 = ”)
- questions.add((questions.size() + 1) + ". " + expr + " = ");
- }
- }
- return questions;
- }
-
- // 生成一道小学题
- private String generateSingle() {
+ protected String generateSingle() {
int operandCount = Utils.getOperandCount();
StringBuilder expr = new StringBuilder();
diff --git a/src/com/mathpaper/question/QuestionChecker.java b/src/com/mathpaper/question/QuestionChecker.java
index ba04293..161b866 100644
--- a/src/com/mathpaper/question/QuestionChecker.java
+++ b/src/com/mathpaper/question/QuestionChecker.java
@@ -1,3 +1,4 @@
+// mathpaper/question/QuestionChecker.java
package com.mathpaper.question;
import com.mathpaper.file.FileHandler;
diff --git a/src/com/mathpaper/question/SeniorQuestionGenerator.java b/src/com/mathpaper/question/SeniorQuestionGenerator.java
index efee16b..b16b375 100644
--- a/src/com/mathpaper/question/SeniorQuestionGenerator.java
+++ b/src/com/mathpaper/question/SeniorQuestionGenerator.java
@@ -1,28 +1,14 @@
+// 修改后的SeniorQuestionGenerator.java
package com.mathpaper.question;
import com.mathpaper.util.Utils;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Random;
-public class SeniorQuestionGenerator implements QuestionGenerator {
- private final QuestionChecker checker = new QuestionChecker();
+public class SeniorQuestionGenerator extends AbstractQuestionGenerator {
private final Random RANDOM = new Random();
@Override
- public List generate(int count, String username) {
- List questions = new ArrayList<>();
- while (questions.size() < count) {
- String expr = generateSingle();
- if (!checker.isDuplicate(username, expr)) {
- questions.add((questions.size() + 1) + ". " + expr + " = ");
- }
- }
- return questions;
- }
-
- // 生成一道高中题(确保含三角函数)
- private String generateSingle() {
+ protected String generateSingle() {
String expr;
do {
int operandCount = Utils.getOperandCount();
diff --git a/src/com/mathpaper/util/Utils.java b/src/com/mathpaper/util/Utils.java
index 4f36474..eed6bf8 100644
--- a/src/com/mathpaper/util/Utils.java
+++ b/src/com/mathpaper/util/Utils.java
@@ -1,3 +1,4 @@
+// mathpaper/util/Utils.java
package com.mathpaper.util;
import java.util.Random;
diff --git a/src/out/production/个人项目1/.idea/.gitignore b/src/out/production/个人项目1/.idea/.gitignore
new file mode 100644
index 0000000..7d05e99
--- /dev/null
+++ b/src/out/production/个人项目1/.idea/.gitignore
@@ -0,0 +1,10 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
+# 依赖于环境的 Maven 主目录路径
+/mavenHomeManager.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/src/out/production/个人项目1/.idea/misc.xml b/src/out/production/个人项目1/.idea/misc.xml
new file mode 100644
index 0000000..03f397c
--- /dev/null
+++ b/src/out/production/个人项目1/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/out/production/个人项目1/.idea/modules.xml b/src/out/production/个人项目1/.idea/modules.xml
new file mode 100644
index 0000000..4cbff6e
--- /dev/null
+++ b/src/out/production/个人项目1/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/out/production/个人项目1/com/.idea/.gitignore b/src/out/production/个人项目1/com/.idea/.gitignore
new file mode 100644
index 0000000..7d05e99
--- /dev/null
+++ b/src/out/production/个人项目1/com/.idea/.gitignore
@@ -0,0 +1,10 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
+# 依赖于环境的 Maven 主目录路径
+/mavenHomeManager.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/src/out/production/个人项目1/com/.idea/misc.xml b/src/out/production/个人项目1/com/.idea/misc.xml
new file mode 100644
index 0000000..03f397c
--- /dev/null
+++ b/src/out/production/个人项目1/com/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/out/production/个人项目1/com/.idea/modules.xml b/src/out/production/个人项目1/com/.idea/modules.xml
new file mode 100644
index 0000000..2c632c8
--- /dev/null
+++ b/src/out/production/个人项目1/com/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/out/production/个人项目1/com/com.iml b/src/out/production/个人项目1/com/com.iml
new file mode 100644
index 0000000..787f398
--- /dev/null
+++ b/src/out/production/个人项目1/com/com.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/out/production/个人项目1/com/mathpaper/file/FileHandler.class b/src/out/production/个人项目1/com/mathpaper/file/FileHandler.class
new file mode 100644
index 0000000..5a24d0c
Binary files /dev/null and b/src/out/production/个人项目1/com/mathpaper/file/FileHandler.class differ
diff --git a/src/out/production/个人项目1/com/mathpaper/main/Main.class b/src/out/production/个人项目1/com/mathpaper/main/Main.class
new file mode 100644
index 0000000..556734d
Binary files /dev/null and b/src/out/production/个人项目1/com/mathpaper/main/Main.class differ
diff --git a/src/out/production/个人项目1/com/mathpaper/question/AbstractQuestionGenerator.class b/src/out/production/个人项目1/com/mathpaper/question/AbstractQuestionGenerator.class
new file mode 100644
index 0000000..310bfb4
Binary files /dev/null and b/src/out/production/个人项目1/com/mathpaper/question/AbstractQuestionGenerator.class differ
diff --git a/src/out/production/个人项目1/com/mathpaper/question/JuniorQuestionGenerator.class b/src/out/production/个人项目1/com/mathpaper/question/JuniorQuestionGenerator.class
new file mode 100644
index 0000000..f921480
Binary files /dev/null and b/src/out/production/个人项目1/com/mathpaper/question/JuniorQuestionGenerator.class differ
diff --git a/src/out/production/个人项目1/com/mathpaper/question/PrimaryQuestionGenerator.class b/src/out/production/个人项目1/com/mathpaper/question/PrimaryQuestionGenerator.class
new file mode 100644
index 0000000..77be9cf
Binary files /dev/null and b/src/out/production/个人项目1/com/mathpaper/question/PrimaryQuestionGenerator.class differ
diff --git a/src/out/production/个人项目1/com/mathpaper/question/QuestionChecker.class b/src/out/production/个人项目1/com/mathpaper/question/QuestionChecker.class
new file mode 100644
index 0000000..f29ac2a
Binary files /dev/null and b/src/out/production/个人项目1/com/mathpaper/question/QuestionChecker.class differ
diff --git a/src/out/production/个人项目1/com/mathpaper/question/QuestionGenerator.class b/src/out/production/个人项目1/com/mathpaper/question/QuestionGenerator.class
new file mode 100644
index 0000000..f124863
Binary files /dev/null and b/src/out/production/个人项目1/com/mathpaper/question/QuestionGenerator.class differ
diff --git a/src/out/production/个人项目1/com/mathpaper/question/SeniorQuestionGenerator.class b/src/out/production/个人项目1/com/mathpaper/question/SeniorQuestionGenerator.class
new file mode 100644
index 0000000..1888463
Binary files /dev/null and b/src/out/production/个人项目1/com/mathpaper/question/SeniorQuestionGenerator.class differ
diff --git a/src/out/production/个人项目1/com/mathpaper/user/Account.class b/src/out/production/个人项目1/com/mathpaper/user/Account.class
new file mode 100644
index 0000000..3704f25
Binary files /dev/null and b/src/out/production/个人项目1/com/mathpaper/user/Account.class differ
diff --git a/src/out/production/个人项目1/com/mathpaper/user/AccountManager.class b/src/out/production/个人项目1/com/mathpaper/user/AccountManager.class
new file mode 100644
index 0000000..c7a8176
Binary files /dev/null and b/src/out/production/个人项目1/com/mathpaper/user/AccountManager.class differ
diff --git a/src/out/production/个人项目1/com/mathpaper/util/Utils.class b/src/out/production/个人项目1/com/mathpaper/util/Utils.class
new file mode 100644
index 0000000..ec29ec7
Binary files /dev/null and b/src/out/production/个人项目1/com/mathpaper/util/Utils.class differ
diff --git a/src/out/production/个人项目1/个人项目1.iml b/src/out/production/个人项目1/个人项目1.iml
new file mode 100644
index 0000000..b107a2d
--- /dev/null
+++ b/src/out/production/个人项目1/个人项目1.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/个人项目1.iml b/src/个人项目1.iml
new file mode 100644
index 0000000..b107a2d
--- /dev/null
+++ b/src/个人项目1.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file