package cn.itcast2.dao.impl;
import cn.itcast2.dao.UserDao;
import cn.itcast2.pojo.User;
public class UserImpl implements UserDao {
private static User[] users = new User[5];
private static int index = 0;
@Override
public boolean login(String username, String password) {
boolean flag = false;
for (int x = 0; x < users.length; x++) {
User user = users[x];
if (user != null) {
if (user.getUsername().equals(username)
&& user.getPassword().equals(password)) {
flag = true;
break;
}
}
}
return flag;
}
@Override
public void regist(User user) {
users[index++] = user;
}
}
|
|