Update Users.java

pull/3/head
hnu202326010305 7 days ago
parent 5ff952dbed
commit ccf30dd651

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