public class UserDB
时间: 2023-10-21 21:36:49 浏览: 88
UserData.class
{ private List<User> userList;
public UserDB() {
userList = new ArrayList<>();
}
public void addUser(User user) {
userList.add(user);
}
public void removeUser(User user) {
userList.remove(user);
}
public User getUserByUsername(String username) {
for (User user : userList) {
if (user.getUsername().equals(username)) {
return user;
}
}
return null;
}
public List<User> getAllUsers() {
return userList;
}
}
阅读全文