首先当我们拿到超市会员卡管理系统这个题的时候,可能会绝对哇,好高大上,其实不然,我们要从心里鄙视它,你很low,等我干掉你!!

然后我们去分析这个题我们用面向对象怎么去解决:

一,超市会员卡?

一个卡绝对会有的属性:  卡号,,姓名,,开卡时间,,密码,,积分是不是??

那么我门就可以先把这个卡类给建立出来

public class CarVip {//首先 我们要建立会员卡的属性    姓名   卡号   密码  积分   开卡时间private String name;private  int carId;private String password;private int socre;private String registDate;//空参构造public CarVip() {}//有参构造public CarVip(String name, int carId, String password, int socre, String registDate) {this.name = name;this.carId = carId;this.password = password;this.socre = socre;this.registDate = registDate;}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getCarId() {return carId;}public void setCarId(int carId) {this.carId = carId;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}public int getSocre() {return socre;}public void setSocre(int socre) {this.socre = socre;}public String getRegistDate() {return registDate;}public void setRegistDate(String registDate) {this.registDate = registDate;}
}

二,会员卡绝对会有业务类去实现会员卡这个类

它的方法都有哪些呢?根据要求总共五个方法:

1,开卡

2,存积分

3,查询积分

4,兑换积分

5,修改密码

6,退出系统

public class CarVipDao {Scanner sc = new Scanner(System.in);List<CarVip> carVipList = new ArrayList();public void startVip() {System.out.println("================================");System.out.println("1,开卡    2,存积分   3,积分查询  4,积分兑换  5,修改密码  6.退出系统");System.out.println("================================");System.out.println("请选择:");}public void start() {do {//让程序进入界面交互部分
            startVip();int choose = sc.nextInt();//让键盘录入去接收switch (choose) {case 1://1,开卡
                    openNewCarId();continue;case 2://2,存积分if(cunScore()){System.out.println("恭喜你,积分累计成功");}else{System.out.println("对不起,积分累计失败");}continue;case 3://3,查询积分
                    chaScore();continue;case 4://4,积分兑换if(duiScore()){System.out.println("恭喜你,积分兑换成功");}else{System.out.println("对不起,积分兑换失败");}continue;case 5://5,修改密码if(checkPas()){System.out.println("恭喜你,密码修改成功");}else{System.out.println("对不起,你的输入有误");}continue;case 6://6退出系统
//                    System.exit(1);break;default:System.out.println("对不起,你的输入有误,请重新输入:");continue;}break;} while (true);}/*** 1,开卡*/public void openNewCarId() {CarVip carVip = new CarVip();//新建卡类对象System.out.println("请输入姓名:");carVip.setName(sc.next());//随机生成卡号carVip.setCarId(this.openNew());//输入密码System.out.println("请输入您的密码:");boolean flag = false;String pas;do {pas = sc.next();if (pas.length() < 6) {System.out.println("对不起,您输入错误,请重新输入:");} else {carVip.setPassword(pas);flag = true;}} while (!flag);//开卡成功后送积分100carVip.setSocre(100);//显示开卡时间Date date = new Date();//系统时间String s = new SimpleDateFormat("yyyy-MM-dd").format(date);carVip.setRegistDate(s);carVipList.add(carVip);System.out.println("恭喜您,开卡成功,为了感谢你对我们的支持,送你100积分,你的会员卡号是:" + carVip.getCarId());}/*** 生成随机卡号** @return*/private int openNew() {Random r = new Random();int i = r.nextInt(99999999);for (CarVip vip : carVipList) {if (i == vip.getCarId()) {i = r.nextInt(99999999);}}return i;}/*** 2,存积分*/public boolean cunScore() {CarVip vip = new CarVip();System.out.println("请输入您的卡号:");vip.setCarId(sc.nextInt());System.out.println("请输入密码:");vip.setPassword(sc.next());if ((vip=hascar(vip))!=null) {System.out.println("请输入你消费的金额:(1元换1积分)");int i = sc.nextInt();vip.setSocre(vip.getSocre()+i);return true;}else{System.out.println("对不起,您输入的账号密码不匹配,请重新输入");}return true;}/*** 判断输入的卡号和密码是否正确* @param carVip* @return*/private CarVip hascar(CarVip carVip) {if (carVip.getPassword() != null) {for (int i = 0; i < carVipList.size(); i++) {//equalsIgnoreCase是不分大小写,需要判断输入的密码是否一样if (carVipList.get(i).getPassword().equalsIgnoreCase(carVip.getPassword()) && carVipList.get(i).getCarId() == carVip.getCarId()) {return carVipList.get(i);}}}return null;}/*** 3,查询积分*/public void chaScore(){CarVip vip = new CarVip();System.out.println("请输入你的卡号:");vip.setCarId(sc.nextInt());System.out.println("请输入你的密码:");vip.setPassword(sc.next());if((vip=hascar(vip))!=null){System.out.println("姓名  卡号  积分  开卡时间");System.out.println(vip.getName()+" "+vip.getCarId()+" "+vip.getSocre()+" "+vip.getRegistDate());}else{System.out.println("对不起,你输入的卡号和密码不匹配,请重新输入");}}/*** 4,兑换积分*/public boolean duiScore(){CarVip vip = new CarVip();System.out.println("请输入你的卡号:");vip.setCarId(sc.nextInt());System.out.println("请输入你的密码:");vip.setPassword(sc.next());if((vip=hascar(vip))!=null){System.out.println("请输入你要兑换的积分:(100积分兑换0.1元,不足100积分不能兑换)");int i = sc.nextInt();if(i<vip.getSocre()){vip.setSocre(vip.getSocre()-i);System.out.println("您的积分兑换成功:"+i/100*0.1+"元");return true;}else{System.out.println("对不起,你的积分不够,不能兑换");}}else{System.out.println("对不起,你输入的卡号和密码不匹配,请重新输入:");}return false;}/*** 5,修改密码*/public boolean checkPas(){CarVip vip = new CarVip();System.out.println("请输入您的卡号:");vip.setCarId(sc.nextInt());System.out.println("请输入您的密码:");vip.setPassword(sc.next());if((vip=hascar(vip))!=null){System.out.println("输入正确,请输入您的新密码:");String pas;boolean flag=false;do{pas=sc.next();if(pas.length()<6){System.out.println("对不起,您输入错误,请重新输入:");flag=false;}else{vip.setPassword(pas);flag=true;}}while (!flag);return true;}else{System.out.println("对不起,您输入的卡号和密码不匹配,请重新输入:");}return false;}
}

三:测试类

public class Test {public static void main(String[] args) {CarVipDao car = new CarVipDao();car.start();}
}

转载于:https://www.cnblogs.com/liurui-bk517/p/10918075.html

##超市会员卡管理,利用我们之前的知识进行温习相关推荐

  1. Java毕业设计-超市综合管理信息系统

    相关资源:java毕业设计-超市综合管理信息系统.zip-互联网文档类资源-CSDN下载 摘 要 由于科技的发展,信息量的剧烈膨胀,企业要想适应信息社会迅猛发展的浪潮,就必须借助于Internet构建 ...

  2. [计算机毕设]基于java的超市积分管理系统设计与实现(项目报告+答辩PPT+源代码+数据库)

    项目说明报告 基于java的超市积分管理系统 随着计算机和网络的不断革新,世界已经进入了前所未有的电子时代.作为实用性强.应用范围广泛的会员管理系统也正在被越来越多的各类企业用于消费管理领域.然而,那 ...

  3. [计算机毕设]基于java的超市综合管理信息系统设计与实现(项目报告+源代码+翻译)

    项目说明报告  基于java的超市综合管理信息系统设计与实现 由于科技的发展,信息量的剧烈膨胀,企业要想适应信息社会迅猛发展的浪潮,就必须借助于Internet构建新的运营模式,连锁超市已经成为很多企 ...

  4. 超市综合管理信息系统

    超市综合管理信息系统 摘 要 由于科技的发展,信息量的剧烈膨胀,企业要想适应信息社会迅猛发展的浪潮,就必须借助于Internet构建新的运营模式,连锁超市已经成为很多企业要采用的新模式.同时J2EE平 ...

  5. SSM毕设项目超市会员卡管理系统dq469(java+VUE+Mybatis+Maven+Mysql)

    SSM毕设项目超市会员卡管理系统dq469(java+VUE+Mybatis+Maven+Mysql) 项目运行 环境配置: Jdk1.8 + Tomcat8.5 + Mysql + HBuilder ...

  6. JAVA编写学校超市选址问题_中小型超市商品管理系统设计与实现【开题报告+文献综述+毕业论文】.docx...

    本科毕业论文开题报告信息管理与信息系统中 小 型 超 市 商 品 管 理 系 统 设 计 与 实 现一.立论依据 1.研究意义.预期目标随着中国经济的不断发展,计算机的普及率越来越高,超市的管理手段发 ...

  7. 【java毕业设计】基于javaEE+SSH+mysql+strust2的超市积分管理系统设计与实现(毕业论文+程序源码)——超市积分管理系统

    基于javaEE+SSH+mysql+strust2的超市积分管理系统设计与实现(毕业论文+程序源码) 大家好,今天给大家介绍基于javaEE+SSH+mysql+strust2的超市积分管理系统设计 ...

  8. 实验10 超市订单管理系统综合实验

    实验10   超市订单管理系统综合实验 应粉丝要求,本博主帮助实现基本效果! 未避免产生版权问题,本项目博主不公开源码,如果您遇到相关问题可私聊博主! 一.实验目的及任务 通过该实验,掌握利用SSM框 ...

  9. 基于Mysql+JavaSwing的超市商品管理系统设计与实现

    文章来源: 学习通http://www.bdgxy.com/ 目录 1.功能介绍 2.关键代码 2.1 主页功能 2.2 添加商品信息 2.3 数据库设计 商品表 前言: 随着小超市规模的发展不断扩大 ...

最新文章

  1. Service的一些使用
  2. Tomcat7目录结构详解(非常详细)
  3. 穿梭框的list集合 去重
  4. C语言实例:3个数从小到大排序
  5. django-form and fields validation
  6. ElasticSearch初体验之使用Java进行最基本的增删改查
  7. faster rcnn resnet_Faster-rcnn 代码详解
  8. 【Flink】Flink netty 通讯 PartitionRequestClient NettyPartitionRequestClient
  9. 输入框值不能赋值成功
  10. linux 代码行数统计利器 ——cloc
  11. 在lamp环境下搭建多种论坛(下)
  12. 中小学生计算机一等奖李广圆,喜报:昌乐一中学生在第二十届全国中小学电脑制作活动中获两项大奖...
  13. 《R语言初学者指南》pdf
  14. mysql修改表只读属性_VF设置的疑问
  15. NB-LoT 云平台对接及使用
  16. C#按汉字拼音首字母排序
  17. nas文件服务器访问限制,nas文件服务器远程访问
  18. 实现php Curl 调用不同项目中方法
  19. (OJ)Java面向对象-构造方法
  20. 拨号服务器是什么,有什么用处?

热门文章

  1. 使用VMwaver 克隆CentOS 6.9网卡配置报错
  2. matlab ri值,基于Matlab的中国地面气候资料日值数据集(V3.0)快速处理
  3. 凯撒密码(移位加密)
  4. 1.学生党如何查找文献书籍
  5. C/C++ fabs 函数 - C语言零基础入门教程
  6. php项目怎么配置admin,PHPadmin配置
  7. 学计算机高中应该学什么科目,@所有高中生!新高考怎么选科?计算机类专业该怎么选科?...
  8. MCU学习——无线遥控模块
  9. 对抖音App评论进行抓取
  10. windows server 2016 下域环境的搭建(完整版)