public class ExamManagementSystem {

private static int studentId;

public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    System.out.println("请选择语言:");
    System.out.println("1. 中文");
    System.out.println("2. English");
    int langChoice = scanner.nextInt();
    switch (langChoice) {
        case 1:
            System.out.println("请选择您的身份:");
            System.out.println("1. 学生");
            System.out.println("2. 老师");
            break;
        case 2:
            System.out.println("Please choose your identity:");
            System.out.println("1. Student");
            System.out.println("2. Teacher");
            break;
    }
    int identityChoice = scanner.nextInt();
    if (identityChoice == 1) {
        // 学生登录逻辑
    } else if (identityChoice == 2) {
        // 老师登录逻辑
        switch (langChoice) {
            case 1:
                System.out.println("请输入用户名:");
                break;
            case 2:
                System.out.println("Please enter your username:");
                break;
        }
        String username = scanner.next();
        switch (langChoice) {
            case 1:
                System.out.println("请输入密码:");
                String password = scanner.next();
                break;
            case 2:
                System.out.println("Please enter your password:");
                String password1 = scanner.next();
                break;
        }

        // 验证用户名和密码是否正确
        if (isValidTeacher(username, password)) {
            switch (langChoice) {
                case 1:
                    System.out.println("你确定现在要登录吗?");
                    System.out.println("A. 是");
                    System.out.println("B. 否");
                    System.out.println("C. 返回首页");
                    break;
                case 2:
                    System.out.println("Are you sure you want to log in now?");
                    System.out.println("A. Yes");
                    System.out.println("B. No");
                    System.out.println("C. Back to the home page");
                    break;
            }
            String choice = scanner.next();
            if (choice.equalsIgnoreCase("A")) {
                // 老师登录成功
                System.out.println("老师登录成功");
                boolean isRunning = true;
                while (isRunning) {
                    switch (langChoice) {
                        case 1:
                            System.out.println("请选择您要进行的操作:");
                            System.out.println("1. 查看问题");
                            System.out.println("2. 添加问题");
                            System.out.println("3. 删除问题");
                            System.out.println("4. 更新问题");
                            System.out.println("5. 退出");
                            break;
                        case 2:
                            System.out.println("Please choose what you want to do:");
                            System.out.println("1. View questions");
                            System.out.println("2. Add question");
                            System.out.println("3. Delete question");
                            System.out.println("4. Update question");
                            System.out.println("5. Exit");
                            break;
                    }
                    int operationChoice = scanner.nextInt();
                    switch (operationChoice) {
                        case 1:
                            // 查看问题
                            System.out.println("查看问题");
                            break;
                        case 2:
                            // 添加问题
                            System.out.println("添加问题");
                            break;
                        case 3:
                            // 删除问题
                            System.out.println("删除问题");
                            break;
                        case 4:
                            // 更新问题
                            System.out.println("更新问题");
                            break;
                        case 5:
                            // 退出
                            isRunning = false;
                            break;
                        default:
                            switch (langChoice) {
                                case 1:
                                    System.out.println("无效的选项!");
                                    break;
                                case 2:
                                    System.out.println("Invalid option!");
                                    break;
                            }
                            break;
                    }
                }
            } else if (choice.equalsIgnoreCase("B")) {
                // 取消登录
                System.out.println("取消登录");
            } else if (choice.equalsIgnoreCase("C")) {
                // 返回首页
                System.out.println("返回首页");
            } else {
                switch (langChoice) {
                    case 1:
                        System.out.println("无效的选项!");
                        break;
                    case 2:
                        System.out.println("Invalid option!");
                        break;
                }
            }
        } else {
            switch (langChoice) {
                case 1:
                    System.out.println("用户名或密码错误!");
                    break;
                case 2:
                    System.out.println("Invalid username or password!");
                    break;
            }
        }
    } else {
        switch (langChoice) {
            case 1:
                System.out.println("无效的选项!");
                break;
            case 2:
                System.out.println("Invalid option!");
                break;
        }
    }
}

// 模拟老师用户名和密码是否匹配的方法
private static boolean isValidTeacher(String username, String password) {
    // 这里可以连接数据库,查询用户名和密码是否匹配
    if (username.equals("teacher") && password.equals("123456")) {
        return true;
    } else {
        return false;
    }
}
public class ExamManagementSystem 	private static int studentId;	public static void mainString args 	 Scanner scanner = new ScannerSystemin;	 Systemoutprintln请选择语言:;	 Systemoutprintln1 中文;

原文地址: https://www.cveoy.top/t/topic/hipa 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录