main
Teptao 5 months ago
parent 4c27ef1966
commit bf2029fdfb

@ -6,4 +6,5 @@
李四3,123,初中
王五1,123,高中
王五2,123,高中
王五3,123,高中
王五3,123,高中
abc1,123,高中

@ -0,0 +1,19 @@
1. (45^2) * (5 - sin(45) - 7 * 94 = ?
2. cos(60) + 74 = ?
3. 47 - cos(45) - 63) = ?
4. 25 / 5 * cos(60) + 88) * (59^2) = ?
5. tan(30) + 8 = ?
6. 59 * cos(45) = ?
7. 91 * tan(0) + 100 / sqrt(9) = ?
8. 55 / tan(60) / 70 / sqrt(64) = ?
9. tan(0) + 69 = ?
10. sin(60) / sqrt(25) = ?

@ -0,0 +1,19 @@
1. 7 - 7 - 0 * 1 = ?
2. 19 + 16 = ?
3. 20 + 37 = ?
4. 8 / 2 = ?
5. 65 + 76 * 7 - 363 - 466 = ?
6. 72 * (5 - 125) = ?
7. 83 * 2 = ?
8. 6 * 2 = ?
9. 56 - 33 = ?
10. 43 / 1 - 41 / 1 = ?

@ -0,0 +1,23 @@
1. 19 * sin(45) + sqrt(25) = ?
2. sin(0) / (10^2) + 91) - 24 = ?
3. (13^2) + (97 - tan(45) = ?
4. sin(45) - sqrt(25) = ?
5. 119 / cos(30) + 12 + (30^2) = ?
6. (12 - (98^2) / sin(90) / 1 * 36 = ?
7. 67 + 53 - 60 / sin(90) * 64 = ?
8. sqrt(81) - 60 + sin(45) + 98 = ?
9. tan(45) - 19) / sqrt(16) = ?
10. 26 + 7 * tan(45) = ?
11. (59 + (97^2) - tan(0) = ?
12. 55 * (49^2) + sin(45) + 35 = ?

@ -29,7 +29,7 @@ public class Application {
*
*/
public Application() {
this.scanner = new Scanner(System.in, "UTF-8");
this.scanner = new Scanner(System.in);
// 创建数据访问层的实例
IUserRepository userRepository = new UserRepository();
@ -44,19 +44,24 @@ public class Application {
*
*
*
* @throws IOException
*/
public void run() throws IOException {
public void run() {
System.out.println("欢迎使用中小学数学卷子自动生成程序!");
while (true) {
if (!sessionManager.isUserLoggedIn()) {
handleLoggedOutState();
} else {
handleLoggedInState();
try {
if (!sessionManager.isUserLoggedIn()) {
handleLoggedOutState();
} else {
handleLoggedInState();
}
} catch (Exception e) {
System.out.println("error");
break;
}
}
}
/**
*
*/
@ -204,9 +209,8 @@ public class Application {
* (main)
* Application
* @param args 使
* @throws IOException IO
*/
public static void main(String[] args) throws IOException {
public static void main(String[] args) {
Application app = new Application();
app.run();
}

@ -21,7 +21,6 @@ public class AuthService implements IAuthService {
*/
public Optional<User> login(String username, String password) {
Optional<User> userOptional = userRepository.findByUsername(username);
// 检查用户是否存在,以及密码是否匹配
if (userOptional.isPresent() && userOptional.get().getPassword().equals(password)) {
return userOptional;

@ -1,31 +1,57 @@
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
/**
*
*
*
*/
public class UserRepository implements IUserRepository {
private final Map<String, User> userDatabase = new ConcurrentHashMap<>();
public UserRepository() {
// 初始化预定义的9个用户账户
// 小学老师
userDatabase.put("张三1", new User("张三1", "123", "小学"));
userDatabase.put("张三2", new User("张三2", "123", "小学"));
userDatabase.put("张三3", new User("张三3", "123", "小学"));
// 初中老师
userDatabase.put("李四1", new User("李四1", "123", "初中"));
userDatabase.put("李四2", new User("李四2", "123", "初中"));
userDatabase.put("李四3", new User("李四3", "123", "初中"));
// 高中老师
userDatabase.put("王五1", new User("王五1", "123", "高中"));
userDatabase.put("王五2", new User("王五2", "123", "高中"));
userDatabase.put("王五3", new User("王五3", "123", "高中"));
// 从文件中加载用户数据
loadUsersFromFile();
}
/**
*
* "username,password,level"
*/
private void loadUsersFromFile() {
// 使用 try-with-resources 语句确保 BufferedReader 被正确关闭
try (BufferedReader reader = new BufferedReader(new FileReader("./account/account.txt"))) {
String line;
// 逐行读取文件
while ((line = reader.readLine()) != null) {
// 使用逗号分割每行的数据
String[] parts = line.split(",");
// 确保每行都有三部分:用户名、密码和用户级别
if (parts.length == 3) {
String username = parts[0].trim();
String password = parts[1].trim();
String level = parts[2].trim();
userDatabase.put(username, new User(username, password, level));
}
}
} catch (IOException e) {
// 如果文件未找到或发生其他IO错误打印错误信息
System.err.println("从文件加载用户数据时出错: " + "./account/account.txt");
}
}
/**
*
*
* @param username
* @return Optional
* Optional
*/
@Override
public Optional<User> findByUsername(String username) {
return Optional.ofNullable(userDatabase.get(username));

@ -0,0 +1,14 @@
@echo off
:: 1. 将控制台环境设置为 UTF-8确保中文输入输出正确
chcp 65001 > nul
:: 2. 告诉 Java 虚拟机(JVM) 使用 UTF-8 编码
set JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8
:: 3. 运行你的 JAR 包
echo loading...
java -jar TestPaperGenerationSystem.jar
:: 4. 清理环境变量并暂停,以便查看程序输出
set JAVA_TOOL_OPTIONS=
pause
Loading…
Cancel
Save