第一步创建Member标准类
public class Member {
private String name;//姓名
private int cardId;//会员卡号
private String password; //密码
private int score;//积分
private String registDate;//开卡日期
//生成默认构造方法
public Member() {
}
//生成带参构造方法
public Member(String name, int cardId, String password, int score) {
this.name = name;
this.cardId = cardId;
this.password = password;
this.score = score;
}
public Member(String name, int cardId, String password, int score, String registDate) {
super();
this.name = name;
this.cardId = cardId;
this.password = password;
this.score = score;
this.registDate = registDate;
}
//生成getXxxx和setXxx方法
public String getRegistDate() {
return registDate;
}
public void setRegistDate(String registDate) {
this.registDate = registDate;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getCardId() {
return cardId;
}
public void setCardId(int cardId) {
this.cardId = cardId;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
}
第二步 创建MemberDao方法查询类
import java.text.SimpleDateFormat;
import java.util.*;
public class MemberDao {
//创建ArrayList集合用于存储数据
List<Member> memberList = new ArrayList<Member>();
//Scanner键盘录入
Scanner input = new Scanner(System.in);
//创建菜单的放法me