parent
68fadea367
commit
99c689c3ce
@ -0,0 +1,73 @@
|
|||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Scanner;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class User {
|
||||||
|
String username;
|
||||||
|
String password;
|
||||||
|
String level;
|
||||||
|
ArrayList<User> list1 = new ArrayList<>();
|
||||||
|
int state = 1;
|
||||||
|
|
||||||
|
public boolean logon() { //登录
|
||||||
|
if (state == 1) {
|
||||||
|
try {
|
||||||
|
new ProcessBuilder("clear").inheritIO().start().waitFor();
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
//e.printStackTrace();
|
||||||
|
}
|
||||||
|
// try {
|
||||||
|
// Runtime.getRuntime().exec("cmd /c cls").waitFor();
|
||||||
|
// } catch (IOException | InterruptedException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
System.out.println("=== 中小学数学卷子自动生成程序 ===");
|
||||||
|
System.out.println("请输入账户名称,密码:");
|
||||||
|
}
|
||||||
|
Scanner sc = new Scanner(System.in);
|
||||||
|
String name = sc.next();
|
||||||
|
String word = sc.next();
|
||||||
|
for (int i = 0; i < list1.size(); i++) {
|
||||||
|
if (name.equals(list1.get(i).username) && word.equals(list1.get(i).password)) {
|
||||||
|
username = name;
|
||||||
|
password = word;
|
||||||
|
level = list1.get(i).level;
|
||||||
|
state = 1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("请输入正确的用户名、密码");
|
||||||
|
state = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
initializeUser();
|
||||||
|
while (logon()) {
|
||||||
|
if (state == 0) {
|
||||||
|
continue;
|
||||||
|
} else if (state == 1) {
|
||||||
|
problem p1 = new problem();
|
||||||
|
p1.start(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public User(String username, String password, String level) {
|
||||||
|
this.username = username;
|
||||||
|
this.password = password;
|
||||||
|
this.level = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeUser() {
|
||||||
|
list1.add(new User("张三1", "123", "小学"));
|
||||||
|
list1.add(new User("张三2", "123", "小学"));
|
||||||
|
list1.add(new User("张三3", "123", "小学"));
|
||||||
|
list1.add(new User("李四1", "123", "初中"));
|
||||||
|
list1.add(new User("李四2", "123", "初中"));
|
||||||
|
list1.add(new User("李四3", "123", "初中"));
|
||||||
|
list1.add(new User("王五1", "123", "高中"));
|
||||||
|
list1.add(new User("王五2", "123", "高中"));
|
||||||
|
list1.add(new User("王五3", "123", "高中"));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue