Update Users.java

pull/3/head
hnu202326010305 2 weeks ago
parent 5ff952dbed
commit ccf30dd651

@ -1,44 +1,47 @@
public class Users { /**
private final String name; *
private final String password; */
private final String type; public class Users {
private final String name;
private static final Users[] USERS = { private final String password;
new Users("张三1", "123", "小学"), private final String type;
new Users("张三2", "123", "小学"),
new Users("张三3", "123", "小学"), private static final Users[] USERS = {
new Users("李四1", "123", "初中"), new Users("张三1", "123", "小学"),
new Users("李四2", "123", "初中"), new Users("张三2", "123", "小学"),
new Users("李四3", "123", "初中"), new Users("张三3", "123", "小学"),
new Users("王五1", "123", "高中"), new Users("李四1", "123", "初中"),
new Users("王五2", "123", "高中"), new Users("李四2", "123", "初中"),
new Users("王五3", "123", "高中") new Users("李四3", "123", "初中"),
}; new Users("王五1", "123", "高中"),
new Users("王五2", "123", "高中"),
public Users(String name, String password, String type) { new Users("王五3", "123", "高中")
this.name = name; };
this.password = password;
this.type = type; public Users(String name, String password, String type) {
} this.name = name;
this.password = password;
public String getType() { this.type = type;
return type; }
}
public String getType() {
public String getName() { return type;
return name; }
}
public String getName() {
public String getPassword() { return name;
return password; }
}
public String getPassword() {
public static Users login(String name, String password) { return password;
for (Users users : USERS) { }
if (users.getName().equals(name) && users.getPassword().equals(password)) {
return users; public static Users login(String name, String password) {
} for (Users users : USERS) {
} if (users.getName().equals(name) && users.getPassword().equals(password)) {
return null; return users;
} }
}
return null;
}
} }
Loading…
Cancel
Save