1、User类
package com.hubstc.Bank;
/*
* 该项目利用Java基础(基本数据类型、for循环、if语句、switch语句、while循环、do-whlie)、数组
* 面向对象(封装、对象的创建与引用)、异常处理(try-catch)、List集合(list、Arraylist)
*/
public class User {
//属性:账号、用户名、用户密码、身份证号、余额
String account;
String userName;
String password;
String id;
double money;
// //方法
// public void showInfo(){
// System.out.println("账号:"+account+",用户名:"+userName+",密码:"+password+",身份证号:"+id);
// }
public double getMoney() {
return money;
}
public void setMoney(double money) {
this.money = money;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
/*
* 用户存款方法 返回更新后的余额
*/
public double UserAddMoney(double money,double addMoney){
if(addMoney > 0){
money += addMoney;
return money;
}else{
System.out.println("存款金额不足,请充值!");
return -1;
}
}
//取款
public int UserCutMoney(double outMoney){
if(outMoney > 0){
if(outMoney < money){
money -= outMoney;
return 1;
}else{
System.out.println("取款金额不能大于账号余额!");
return -1;
}