笔试题:编写一个用户注册接口
用户类:UserBean
用户操作类接口:UserDao
接口实现类:DaoImpl
用户测试类:UserTest
public class UserBean{
private String username; private String password; public UserBean(String name,String password){ this.username=username; this.password=password; } public void setName(String name){ this.username=name; } public String getName(){ return this.username; } public void setPass(String pswd){ this.password=pswd; } public String getPass(){ return this.password; }
}
public interface UserDao{
public abstract boolean register(UserBean user);
}
public class DaoImpl implements UserDao{
ArrayList<UserBean> list=new ArrayList<UserBean>(); public boolean register(Userbean user){boolean flag=true; list.add(user); return true; }
public class UserTesr{ public static void main(String args[]){ UserDao ud=new UserDao(); UserBean user=new UserBean("双双","123456"); if(ud.register(user)){ System.out.println"注册成功!"); } else{ System.out.println("注册失败!"); } } }