import java.io.*;
import java.util.ArrayList;

public class Account {
    private String username;
    private String password;
    private static ArrayList<Account> accounts = new ArrayList<Account>();
    private String authority;

    public static ArrayList<Account> getAccounts() {
        return accounts;
    }

    public static void setAccounts(ArrayList<Account> accounts) {
        Account.accounts = accounts;
    }

    public Account() {
    }

    public Account(String authority) {
        this.setAuthority(authority);
        try {
            readUser();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public String getAuthority() {
        return authority;
    }

    public void setAuthority(String authority) {
        this.authority = authority;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void readUser() throws IOException {
        FileInputStream fileInputStream = null;
        if (getAuthority().equals("管理员")) {
            fileInputStream = new FileInputStream("./lib/teacher.txt");
        } else if (getAuthority().equals("学生")) {
            fileInputStream = new FileInputStream("./lib/student.txt");
        }
        BufferedReader br = new BufferedReader(new InputStreamReader(fileInputStream));
        String line;
        while ((line = br.readLine()) != null) {
            String[] arr = line.split("\\s+");
            Account account = new Account();
            account.setUsername(arr[0]);
            account.setPassword(arr[1]);
            accounts.add(account);
        }
        setAccounts(accounts);
        br.close();
        fileInputStream.close();
    }
}
最近下载更多
wanglinddad  LV55 3月9日
fenghuijun  LV26 1月13日
计算机暴龙战士  LV19 1月5日
305865088  LV7 2023年12月15日
Seaskye  LV14 2023年11月28日
2410068425  LV23 2023年11月27日
最代码官方  LV167 2023年11月26日
最近浏览更多
泓鼎168  LV19 4月30日
kenhomeliu  LV29 4月30日
getset  LV8 4月24日
pangzhihui  LV13 4月15日
zolscy  LV12 4月5日
zzz9985688  LV10 4月2日
小小可爱 3月17日
暂无贡献等级
a318888331  LV13 3月10日
wanglinddad  LV55 3月9日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友