java基础练习0723:会员系统(含代码、改进点

本文介绍了基于Java实现的会员系统,包括积分累计、积分兑换和查询等功能。代码中涉及了VipMember类和VipSystem类的设计,通过迭代器进行登录验证。改进点包括将操作类中的case内容改为独立方法,密码忽略大小写,以及优化积分计算和兑换的逻辑。
摘要由CSDN通过智能技术生成

待改进


  • 业务逻辑更符合

在这里插入图片描述

  • 操作类中的case里的内容改写为方法,case只需要进行方法的调用

  • 密码 不在乎大小写

代码


VipMember.java:VIp成员类

package Test_vipSystem;

public class VipMember {

private String name;

private String accountNumber;

private String password;

private int point;

public VipMember(){

}

public VipMember(String name, String accountNumber, String password, int point) {

this.name = name;

this.accountNumber = accountNumber;

this.password = password;

this.point = point;

}

public void pointSum(double consumptionMoney){

//floor(3.14) 结果是3.0是double 并不是整数类型

// setPoint(Math.floor(consumptionMoney));//出错? 不兼容的类型: 从double转换到int可能会有损失

int temp = (int)Math.floor(consumptionMoney);//强制类型转换

setPoint(temp+getPoint());

System.out.println(“积分成功!”);

}

public double exchangeCaculate(int exchangePoint){

if(point >= 100&& point>exchangePo

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值