请问 黑体加粗大的部分,为什么会报错,有人说是username和passname重名,但是我改了名字后eclipse还是照样报错的!
package user;
//用户类
public class User {
private String username;
private int password;
public User(){}
public User(String username,int password){
this.username = username;
this.password=password;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public int getPassword() {
return password;
}
public void setPassword(int password) {
this.password = password;
}
}
package user_jiekou;
import user.User;
/**
* 用户操作的接口
*/
public interface UserDao {
/**
* 这是注册的功能
* @param username
* 用户名
* @param password
* 密码
*@return 返回登录是否成功
*/
public abstract boolean login(String usernane,int password);
/**
* 这是用户注册的功能
* @param user
* 要注册的用户
*/
public abstract void regist(User user);
}
package UserDaoImp;
import user.User;
import user_jiekou.UserDao;
/**
* 用户操作实现类
* */
public class UserDaoImp extends User implements UserDao {
public static User[] users = new User[5];//对象数组,用于存储数据
public static int index =0;//对象数组索引
public boolean login(String username,int password){
boolean flag =false;
for (int i = 0; i < users.length; i++) {
User user = users; //遍历对象
if(user!=null) {
if(user.getUsername().equals(username) && user.getPassword().equals(password))
{
flag = true;
break;
}
}
}
return flag;
}
public void regist(User user){
users[index++] = user;
}
}
|
|