会员信息类
package shopping; public class Shop { //属性 private String name; private int memberNo; //会员卡号 private String code; //密码 private int memberIntegral; //会员积分 private String date; //开卡日期 //get set public String getName() { return name; } public void setName(String name) { this.name = name; } public int getMemberNo() { return memberNo; } public void setMemberNo(int memberNo) { this.memberNo = memberNo; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public int getMemberIntegral() { return memberIntegral; } public void setMemberIntegral(int memberIntegral) { this.memberIntegral = memberIntegral; } public String getDate() { return date; } public void setDate(String date) { this.date = date; } //构造方法 public Shop() { } public Shop(String name, int memberNo, String code, int memberIntegral, String date) { super(); this.name = name; this.memberNo = memberNo; this.code = code; this.memberIntegral = memberIntegral; this.date = date; } //重写to String @Override public String toString() { return "Shop [name=" + name + ", memberNo=" + memberNo + ", code=" + code + ", memberIntegral=" + memberIntegral + ", date=" + date + "]"; } }测试实现类
package shopping; import java.text.SimpleDateFormat; import java.util.Date; import java.util.linkedList; import java.util.Scanner; import java.util.List; public class demo { public static void main(String[] args) { Scanner input = new Scanner(System.in); //日期 Date date = new Date(); SimpleDateFormat formater = new SimpleDateFormat("yyyy- MM-dd HH:mm:ss"); String now = formater.format(date); // System.out.println(now); // 假数据 Shop s1 = new Shop("张三", 10001, "abc", 100, "2022- 01-23 10:12:07"); Shop s2 = new Shop("李四", 10002, "abc", 200, "2022- 01-23 10:13:12"); // 创建会员信息数组 linkedListshopList = new linkedList<>(); //添加假数据 shopList.add(s1); shopList.add(s2); // 编写系统 do { int choice = 0; int a=0; System.out.println("******************************欢迎进入超市会员管理系统*******************************"); System.out.print("1、积分累计 t"); System.out.print("2、积分兑换 t"); System.out.print("3、查询剩余积分 t"); System.out.print("4、修改密码 t"); System.out.print("5、开卡 t"); System.out.println("6、退出"); System.out.println("*****************************************************************************"); System.out.println("请选择序号:"); choice = input.nextInt(); switch (choice) { case 1: System.out.println("请输入您的会员卡号:"); int yourNo = input.nextInt(); System.out.println("请输入您的密码:"); String yourCode = input.next(); System.out.println("请输入您此次消费金额(消费1元累计1积分):"); int yourPrice = input.nextInt(); for(int i=0;i 测试结果
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)