diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 72891a1..c57000b 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -9,9 +9,10 @@
-
-
+
+
+
@@ -138,7 +139,23 @@
1758860571386
-
+
+
+ 1758865646973
+
+
+
+ 1758865646973
+
+
+
+ 1758865880181
+
+
+
+ 1758865880181
+
+
@@ -175,6 +192,7 @@
-
+
+
\ No newline at end of file
diff --git a/out/production/TestPaperGenerationSystem/Application.class b/out/production/TestPaperGenerationSystem/Application.class
index 0592030..59707bd 100644
Binary files a/out/production/TestPaperGenerationSystem/Application.class and b/out/production/TestPaperGenerationSystem/Application.class differ
diff --git a/src/Application.java b/src/Application.java
index 17e56e9..a52259e 100644
--- a/src/Application.java
+++ b/src/Application.java
@@ -45,38 +45,44 @@ public class Application {
* 该方法会持续监听用户输入,并根据用户当前的登录状态(已登录或未登录),
* 分别调用不同的处理逻辑。
*/
- public void run() throws IOException {
+ public void run() {
System.out.println("欢迎使用中小学数学卷子自动生成程序!");
-
-
+ while (true) {
+ try {
if (!sessionManager.isUserLoggedIn()) {
- handleLoggedOutState();
+ if(handleLoggedOutState()){
+ System.out.println("感谢使用,程序已退出。");
+ System.exit(0);
+ break;
+ }
} else {
handleLoggedInState();
}
-
+ } catch (Exception e) {
+ System.out.println("error");
+ break;
+ }
}
-
+ }
/**
* 处理用户未登录状态下的逻辑。
*/
- private void handleLoggedOutState() {
- System.out.print("请输入用户名和密码(以空格隔开,输入 'exit' 退出程序): ");
+ private boolean handleLoggedOutState() {
+ System.out.println("请输入用户名和密码(以空格隔开,输入 'exit' 退出程序): ");
String input = scanner.nextLine();
// 检查用户是否希望退出
if ("exit".equalsIgnoreCase(input.trim())) {
- System.out.println("感谢使用,程序已退出。");
- System.exit(0);
+ return true;
}
// 按空格分割输入,获取用户名和密码
String[] credentials = input.split(" ");
if (credentials.length != 2) {
System.out.println("输入格式错误,请输入正确的用户名、密码。");
- return;
+ return false;
}
// 调用认证服务进行登录验证
@@ -89,6 +95,7 @@ public class Application {
// 登录失败,提示用户
System.out.println("用户名或密码错误,请重试。");
}
+ return false;
}
/**
@@ -207,7 +214,7 @@ public class Application {
* 负责创建 Application 实例并启动主循环,从而开始整个程序。
* @param args 命令行参数(本项目中未使用)
*/
- public static void main(String[] args) throws IOException {
+ public static void main(String[] args) {
Application app = new Application();
app.run();
}