学习信息管理系统
Admin类
package com.lll.bank;
public class Admin {
//管理员账号
private String account;
//管理员密码
private String password;
//有参构造方法
public Admin(String account, String password) {
super();
this.account = account;
this.password = password;
}
//无参构造方法
public Admin() {
super();
}
//属性(账号,密码)get/set方法
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
银行类
package com.lll.bank;
public class Bank {
private String name;//银行名
private String cardNum;//银行卡号
public Bank(String name) {
this.name = name;
}
public Bank() {
super();
}
public Bank(String name, String cardNum) {
super();
this.name = name;
this.cardNum = cardNum;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCardNum() {
return cardNum;
}
public void setCardNum(String cardNum) {
this.cardNum = cardNum;
}
}
用户界面类
package com.lll.bank;
import com.lll.bank.Customer;
public class BankCustomerMethod {
BankUtils bkUtils = new BankUtils();
Customer cust = new Customer();
/**
*
* 本方法整合用户的 功能实现 1.存钱 2.取钱 3.修改密码 4.查看个人信息 5.返回上一级
*
* @param
*/
public void bankCustomerMethod(Customer customer) {
boolean isExit = true;
while(isExit) {
System.out.println("请选择你需要进行的操作:1.存钱 2.取钱 3.修改密码 4.查看个人信息 5.返回上一级");
int customerSelect = bkUtils.getReadInt();
switch (customerSelect) {
case 1:
//1.存钱
System.out.println("存钱");
cust.addMoney(customer);
break;
case 2:
//2.取钱
System.out.println("取钱");
cust.deleteMoney(customer);
break;
case 3:
//3.修改密码
System.out.println("修改密码");
cust.updaterCustomerPsd(customer);
break;
case 4:
//查看个人信息
System.out.println("查看个人信息");
cust.displayCustomer(customer);
break;
case 5:
System.out.println("返回上一级");
isExit = false;
break;
default:
System.out.println("系统操作错误!!!");
break;
}
}
//return customer;
}
public Customer sysCustomerDengLu(Customer [] customers) {
for(int x = 1 ; x <= 3 ; x++) {
//获取输入的用户账号
System.out.println("请输入用户账号:");
String account = bkUtils.getReadString();
//获取输入的用户密码
System.out.println("请输入用户密码:");
String psd = bkUtils.getReadString();
/*
* 循环遍历所有管理员账号,密码;
* 如果输入的管理员账号存在,则用verificatAccount存储账号
* 如果输入的管理员账号密码,则用verificatPsd存储密码
* 并把该对象返回 ,使用admin存储
*/
String verificatAccount = null;
String verificatPsd = null;
Customer customer = null ;
for(int y = 0 ; y < customers.length; y++) {
if(customers[y].getAccount().equals(account)) {
verificatAccount = customers[y].getAccount();
verificatPsd = customers[y].getPassword();
customer = customers[y];
break;
}
}
/*
* 如果verificatAccount和verificatPsd为null
* 都为null:则说明输入的管理员账号,密码不存在,显示该管理员不存在提示
* verificatAccount为null:则说明输入的管理员账号不存在,显示该管理员账号不存在提示
* verificatPsd为null:则说明输入的管理员密码不存在,显示该管理员密码错误提示
*/
if(verificatAccount == null) {
System.out.println("该用户账号不存在!!!你还有"+(3-x)+"次机会!");
}else if(!verificatPsd.equals(psd)) {
System.out.println("用户密码错误!!!你还有"+(3-x)+"次机会!");
}else if(verificatAccount != null && verificatPsd != null) {
System.out.println("登陆成功");
return customer;
}
//登陆失败只限3次,3次之后冻结
if((3-x) == 0) {
System.out.println("你已被冻结,请联系老师解决。");
}
}
return null;
}
}
管理员界面类
package com.lll.bank;
import com.lll.bank.BankUtils;
import com.lll.bank.Customer;
/**
* 银行管理系统管理员功能封装
*
*/
public class BankSysMethod {
BankUtils bkUtils = new BankUtils() ;
//存储登陆的管理员
Admin admin = null ;
/**
* 此方法用于管理员登陆,整合了账号,密码验证方法
* @return true 登陆成功 | false 登陆失败
*/
public Admin sysRootDengLu(Admin [] admins) {
for(int x = 1 ; x <= 3 ; x++) {
//获取输入的管理员账号
System.out.println("请输入管理员账号:");
String account = bkUtils.getReadString();
//获取输入的管理员密码
System.out.println("请输入管理员密码:");
@SuppressWarnings("unused")
String psd = bkUtils.getReadString();
/*
* 循环遍历所有管理员账号,密码;
* 如果输入的管理员账号存在,则用verificatAccount存储账号
* 如果输入的管理员账号密码,则用verificatPsd存储密码
* 并把该对象返回 ,使用成员变量admin存储
*/
String verificatAccount = null;
String verificatPsd = null;
for(int y = 0 ; y < admins.length; y++) {
if(admins[y].getAccount().equals(account)) {
verificatAccount = admins[y].getAccount();
verificatPsd = admins[y].getPassword();
admin = admins[y];
break;
}
}
/*
* 如果verificatAccount和verificatPsd为null
* 都为null:则说明输入的管理员账号,密码不存在,显示该管理员不存在提示
* verificatAccount为null:则说明输入的管理员账号不存在,显示该管理员账号不存在提示
* verificatPsd为null:则说明输入的管理员密码不存在,显示该管理员密码错误提示
*/
if(verificatAccount == null) {
System.out.println("该管理员账号不存在!!!你还有"+(3-x)+"次机会!");
}else if(!psd.equals(verificatPsd)) {
System.out.println("管理员密码错误!!!你还有"+(3-x)+"次机会!");
}else if(verificatAccount != null && verificatPsd != null) {
System.out.println("登陆成功");
return admin;
}
//登陆失败只限3次,3次之后冻结
if((3-x) == 0) {
System.out.println("你已被冻结,请联系老师解决。");
}
}
return null;
}
//关于Customer的操作方法都存储在Customer类,通过创建Customer对象来调用
Customer cust = new Customer();
/**
* 此方法用于对管理员功能的总的整合
*
*/
public void sysRootMethod(Customer [] customers) {
boolean isExit = true;
while(isExit) {
System.out.println();
System.out.println("请选择你需要进行的操作:1.查看用户信息 2.修改用户信息 3.增加用户 4.删除用户 5.返回上一级");
int sysMenu = bkUtils.getReadInt();
switch (sysMenu) {
case 1:
//查看用户信息
System.out.println("查看用户信息");
cust.printAllCustomer(customers);
break;
case 2:
//修改用户信息
System.out.println("修改用户信息");
cust.updateUser(customers);
break;
case 3:
//增加用户
System.out.println("增加用户信息");
Customer[] newCustomers = cust.addCustomer(customers);
//这里的查询用户传进的是Customer[] customer ,所以需要把把扩容后添加进新用户的数组赋值给customer;
customers = newCustomers;
break;
case 4:
//删除用户 [1,2,3,4,5] [1,2,null,4,5] -- [,1,2,4,null,5] -- [1,2,3,4,null] .length - 2
System.out.println("删除用户");
Customer[] deleteCustomer = cust.deleteCustomer(customers);
//这里的查询用户传进的是Customer[] customer ,所以需要把减容后的新用户的数组赋值给customer;
customers = deleteCustomer;
break;
case 5:
isExit = false;
break;
default:
System.out.println("系统操作错误!!!");
break;
}
}
//return customer;
}
}
主界面
package com.lll.bank;
import com.lll.bank.Bank;
public class BankTest {
public static void main(String[] args) {
//银行对象
Bank bk = new Bank("中国招商银行");
//银行工具类
BankUtils bkUtils = new BankUtils();
//拿到模拟数据
DataBase db = new DataBase();
Admin [] admins = db.getAdmin();
Customer[] customers = db.getCostomer();
//银行管理系统管理员功能封装
BankSysMethod bkSysMethod = new BankSysMethod();
//银行管理系统用户功能封装
BankCustomerMethod bkCustomerMethod = new BankCustomerMethod();
//存储登陆的管理员
Admin admin = null;
//存储登陆的用户
Customer customer = null;
//判断是否退出
Boolean isExit = true;
do {
//登陆界面
System.out.println("Welcome to the use "+bk.getName()+"系统,请根据你的需求选择你需要的操作");
System.out.println("***************请选择:1.管理员登陆 ,2.用户登陆,3.退出***************");
//获取输入的 int 类型的值
int selectMenu = bkUtils.getReadInt();
switch (selectMenu) {
case 1:
//1、管理员登陆验证,并把登陆的管理员返回
admin = bkSysMethod.sysRootDengLu(admins);
if(admin == null) {
return;
}
System.out.println(admin);
bkSysMethod.sysRootMethod(customers);
break;
case 2:
customer = bkCustomerMethod.sysCustomerDengLu(customers);
if(customer == null) {
return;
}
bkCustomerMethod.bankCustomerMethod(customer);
System.out.println("用户登陆成功");
break;
case 3:
isExit = false;
System.out.println("退出成功");
break;
default:
System.out.println("你的输入有误,请重新输入!!!");
break;
}
} while (isExit);
}
}
工具类
package com.lll.bank;
import java.util.Scanner;
import com.lll.bank.Customer;
public class BankUtils {
/**
*
* 返回一个手动输入的字符串值
* @return String
*/
public String getReadString() {
Scanner sc = new Scanner(System.in);
String string = sc.nextLine();
return string;
}
/**
*
* 返回一个手动输入的字符串值,如果输入的值为null,则给定默认值
* @return String
*/
public String getReadString(String str,String shuxing) {
Scanner sc = new Scanner(System.in);
String string = sc.nextLine();
if(string.length() == 0 || string == null ) {
string = str;
System.out.print("你此次未输入更改数据,该成员"+shuxing+":"+str+",属性值未变动");
System.out.println();
}
return string;
}
/**
*
* 返回一个手动输入的int值
* @return int
*/
public int getReadInt() {
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
return num;
}
/**
*
* 返回一个手动输入的int值,如果输入的值为null,则给定默认值
* @return int
*/
public int getReadNum(int nums) {
Scanner sc = new Scanner(System.in);
String numStr = sc.nextLine();
if(numStr == null || numStr.length() == 0 ) {
return nums;
}
return nums;
}
/**
*
* 返回一个手动输入的double值
* @return double
*/
public double getReadDouble() {
Scanner sc = new Scanner(System.in);
String numStr = sc.nextLine();
double parseDouble = (double)Integer.parseInt(numStr);
return parseDouble;
}
/**
*
* 返回一个手动输入的double值,如果输入的值为null,则给定默认值
* @return double
*/
public double getReadDouble(double doubl , String shuxing) {
Scanner sc = new Scanner(System.in);
String numStr = sc.nextLine();
double parseInt;
if(numStr == null || numStr.length() == 0 ) {
System.out.print("你此次未输入更改数据,该成员"+shuxing+":"+doubl+",属性值未变动");
System.out.println();
return doubl;
}else {
parseInt = (double)Integer.parseInt(numStr);
}
return parseInt;
}
/**
* 获得一个输入的数据,并判断该数据的数据类型
* 如果输入的是数字,则说明输入符合规范,返回false ,停止循环,输入存钱值符合规范;
* 如果输入的是其他字符,则不符合输入规范,返回一个true ,继续循环输入,直到输入的值为数字;
*/
public boolean isInt(String input) {
// if (Integer.parseInt(input) == -1) {
// System.out.println("已退出存钱!");
// return false;
// }
for (char c : input.toCharArray()) {
if (Character.getType(c) == Character.OTHER_LETTER) {
System.out.println("输入错误!!!你输入的是 中文 ,请重新输入此次存钱数");
return true;
} else if (Character.isDigit(c)) {
return false;
} else if (Character.isLetter(c)) {
System.out.println("输入错误!!!你输入的是 英文字母 ,请重新输入此次存钱数");
return true;
} else {
System.out.println("输入错误!!!你的输入不符合规范,请重新输入此次存钱数");
return true;
}
}
return false;
}
/**
* 判断输入的用户账号是否已存在数据库中;
* 如果已经存在该用户数据中,则显示重新输入;
* 如果不存在该用户数据,则继续输入密码;
* @return 返回一个true 说明有该用户账户数据 | 返回一个false ,说明无该用户账号数据
*/
public boolean verificationIsSame(Customer [] customer , String account) {
boolean isFind = false ;
for(int x = 0 ; x < customer.length ; x++) {
if(customer[x].getAccount().equals(account)) {
System.out.println("该账号已存在,请重新输入!!!");
isFind = true;
return isFind;
}
}
return isFind;
}
/**
*
* 此方法用于对数组进行扩容,在本系统中,对用户的初始化长度为10。
* 判断传进来的数组长度:如果长度大于等于10,下一次添加时数组就需要扩容;
* 本方法每次对数组扩容 1 长度
* @param object
* @return Object[]
*/
public Customer[] addCapacity(Customer [] customer) {
Customer [] newCustomer = new Customer[customer.length + 1] ;
//判断传进来的数组长度是否大于等于10
if(customer.length >= 10) {
//如果数组长度大于等于10,把object数组的值赋值给newObj
for(int x = 0 ; x < customer.length ; x++) {
newCustomer[x] = customer[x];
}
}
return newCustomer;
}
}
客户类
package com.lll.bank;
import java.util.Scanner;
import com.lll.bank.BankUtils;
import com.lll.bank.Customer;
/**
* 客户
*
*/
public class Customer {
//客户属性
private String name;//用户
private String account;//用户账号
private String password;//用户密码
private double balance; //用户余额
private String phone; //用户手机号
//toString方法
public String toString() {
return "Customer [name=" + name + ", account=" + account + ", password=" + password + ", balance="
+ balance + ", phone=" + phone + "]";
}
//客户无参构造方法
public Customer() {
super();
}
//客户有参构造方法
public Customer(String name, String account, String password, double balance, String phone) {
super();
this.name = name;
this.account = account;
this.password = password;
this.balance = balance;
this.phone = phone;
}
//属性get/set方法
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
/**
* 此方法将打印所有的用户信息数据
* 如果没有用户信息,则显示 无用户信息可查询。
*/
public void printAllCustomer(Customer[] customer) {
if(customer.length == 0) {
System.out.println("没有可查询的用户信息!");
return;
}
System.out.println("序号\t用户名\t\t\t用户账号\t用户密码\t用户余额\t用户手机号");
for(int x = 0 ; x < customer.length ; x++) {
String name = customer[x].getName();//用户
String account = customer[x].getAccount();//用户账号
String password = customer[x].getPassword();//用户密码
double balance = customer[x].getBalance(); //用户余额
String phone = customer[x].getPhone(); //用户手机号
System.out.println((x+1)+ "\t" + name + "\t\t" + account + "\t\t" + password + "\t\t" + balance + "\t\t" + phone );
}
}
BankUtils bkUtils = new BankUtils();
/*
*管理员对用户的信息修改功能
*/
public void updateUser(Customer[] customer) {
//获得需要修改的用户账号
System.out.println("请输入你需要修改的用户账号:");
String updateAccount = bkUtils.getReadString();
//如果有该账号,记录该账号的下标。
int index = -1;
for(int x = 0 ; x < customer.length ; x++) {
if(customer[x].getAccount().equals(updateAccount)) {
index = x;
}
}
//根据用户序号修改用户信息
if(index != -1) {
String name = customer[index].getName();//用户
String password = customer[index].getPassword();//用户密码
double balance = customer[index].getBalance(); //用户余额
String phone = customer[index].getPhone(); //用户手机号
System.out.println("----------------------------------------------");
System.out.println("如无需改动用户的属性,直接回车即可");
System.out.println("----------------------------------------------");
System.out.println();
System.out.println("请输入新用户名("+name+"):");
String newName = bkUtils.getReadString(name,"用户名");
System.out.println("请输入用户新密码("+password+"):");
String newPassword = bkUtils.getReadString(password,"用户密码");
System.out.println("请输入用户余额("+balance+"):");
double newBalance = bkUtils.getReadDouble(balance,"用户余额");
System.out.println("请输入用户手机号("+phone+"):");
String newPhone = bkUtils.getReadString(phone,"用户手机号");
customer[index].setName(newName);
customer[index].setPassword(newPassword);
customer[index].setBalance(newBalance);
customer[index].setPhone(newPhone);
System.out.println("修改成功");
}else {
System.out.println("修改失败,你输入的用户序号不存在!!!");
}
}
//存储扩容后的数组
Customer [] newCustomers ;
public Customer[] addCustomer(Customer [] customers) {
/*
* 需要添加的对象数据
* private String name;//用户
* private String password;//用户密码
* private double balance; //用户余额
* private String phone; //用户手机号
*
*/
System.out.println("---------------添加开始---------------");
System.out.println("请输入添加的客户用户名:");
String name = bkUtils.getReadString();
//判断输入的用户账号是否相同;
String account = null ;
boolean isFlag = true;
while(isFlag) {
System.out.println("请输入添加的客户账号:");
account = bkUtils.getReadString();
boolean verificationIsSame = bkUtils.verificationIsSame(customers, account);
isFlag = verificationIsSame;
}
System.out.println("请输入添加的客户密码:");
String password = bkUtils.getReadString();
System.out.println("请输入添加的客户余额:");
double blance = bkUtils.getReadDouble();
System.out.println("请输入添加的客户手机号:");
String phone = bkUtils.getReadString();
Customer newCustomer = new Customer(name , account , password , blance , phone);
/**
* 往对象里面添加新数据,要判断数据的长度,如果数组长度大于等于10,则每次添加数据需要对数组进行动态扩容。
*
*/
//数组扩容
newCustomers = bkUtils.addCapacity(customers);
newCustomers[customers.length] = newCustomer;
System.out.println("---------------添加完成---------------");
return newCustomers;
}
/**
* 根据序号删除客户信息
* @param customer
* @return
*/
public Customer[] deleteCustomer(Customer [] customer) {
/*
*
* 用户删除:
* 1.获得输入需要删除的序号
* 2.判断输入的序号是否存在
* (1)获得指定序号得用户账号;
* (2)遍历循环数组,查看数组中是否存在 获得得指定用户账号。如果存在,记录下该数组下标
* 3.如果序号存在,则根据序号删除用户; 如果序号不存在,则提示删除失败,并返回管理员界面;
* (1)删除数组中得指定用户,其实就是把该位置下标的数据用后一位下标的数组下标替换;
* (2)重新创建一个新的数组接收减容后的数组
* 4.返回一个删除指定序号用户的数组Customer []
*/
//1.获得输入需要删除的序号
System.out.println("请输入你需要删除的客户序号:");
int deleteInt = bkUtils.getReadInt();
//2.判断输入的序号是否存在
//(1)获得指定序号得用户账号;
String deleteAccount = customer[deleteInt - 1].getAccount();
// (2)遍历循环数组,查看数组中是否存在 获得得指定用户账号。
//记录该数组下标;
int index = -1;
for(int x = 0 ; x < customer.length ; x++) {
//因为不能直接获得序号,所以可以根据序号获得该序号得顺序,并判断该数组里面是否存在该账号;
// 如果不存在,则说明已删除过,删除失败。
if(customer[x].getAccount().equals(deleteAccount)) {
index = x;
}
}
//做一下判断,如果要删除的账号还有余额,则不能删除。
if(customer[index].getBalance() != 0) {
System.out.println("---------------该账号用户余额不为0,删除失败!!!---------------");
System.out.println();
return customer;
}
/*
*3.如果序号存在,则根据序号删除用户; 如果序号不存在,则提示删除失败,并返回管理员界面;
* (1)删除数组中得指定用户,其实就是把该位置下标的数据用后一位下标的数组下标替换;
* (2)数组减容。
*/
//定义数组接收减容后的数据
Customer [] deleteCustomer = new Customer[customer.length - 1];
if(index != -1) {
for(int d = index ; d < customer.length - 1; d++) {//数组最后一位数据无需替换
//替换数组数据
customer[d] = customer[d+1];
}
//数组减容
for(int e = 0; e < customer.length - 1 ; e++) {
deleteCustomer[e] = customer[e];
}
System.out.println("---------------删除成功---------------");
}else {
System.out.println("---------------未找到该序号用户,删除失败!!!---------------");
System.out.println();
return customer;
}
return deleteCustomer;
}
/**
* 本方法用于对用户存钱的功能实现;
*
* @param customer
*
*/
public void addMoney(Customer dengLuCustomer) {
/*
* 获得用户存钱数量,根据用户修改用户的余额。
* 1.获得用户存钱数量。
* 2.对用户存钱数量进行校验
* (1)不能为负数
* (2)类型只能为数字。
* 3.校验完成之后,修改该用户余额数
* 4.返回数据。
*
*/
/*
* 1.获得用户存钱数量。
* 2.对用户存钱数量进行校验
* (1)不能为负数
* (2)类型只能为数字。
*/
boolean isInt = true ;
String input = null ;
int addMoneyNum = 0;
while(isInt) {
System.out.println("请输入你本次存钱数量:");
@SuppressWarnings("resource")
Scanner scanner = new Scanner(System.in);
input = scanner.next();
isInt = bkUtils.isInt(input);
}
//3.校验完成之后,修改该用户余额数
if(!isInt) {
addMoneyNum = Integer.parseInt(input);
double momey =dengLuCustomer.getBalance();
dengLuCustomer.setBalance(addMoneyNum + momey);
System.out.println("---------------存钱成功---------------");
System.out.println();
System.out.println("您当前余额为"+dengLuCustomer.getBalance());
}else {
System.out.println("---------------存钱失败---------------");
}
}
/**
* 本方法用于对用户取钱的功能实现;
* @param dengLuCustomer
*/
public void deleteMoney( Customer dengLuCustomer) {
/*
* 获得用户取钱数量,根据用户修改用户的余额。
* 1.获得用户存钱数量。
* 2.对用户存钱数量进行校验
* (1)不能为负数
* (2)取钱数不能大于存钱数。
* 3.校验完成之后,修改该用户余额数
* 4.返回数据。
*
*/
boolean isInt = true ;
String input = null ;
int deleteMoneyNum = 0;
while(isInt) {
System.out.println("请输入你本次取钱数量:");
@SuppressWarnings("resource")
Scanner scanner = new Scanner(System.in);
input = scanner.next();
isInt = bkUtils.isInt(input);
}
//3.校验完成之后,修改该用户余额数
if(!isInt ) {
if(Integer.parseInt(input) > dengLuCustomer.getBalance()) {
isInt = true;
System.out.println("账户余额不足!本次取款数大于余额,请重新输入!!!");
System.out.println();
}
deleteMoneyNum = Integer.parseInt(input);
double momey =dengLuCustomer.getBalance();
dengLuCustomer.setBalance(momey - deleteMoneyNum);
System.out.println("---------------取钱成功---------------");
System.out.println();
System.out.println("您当前余额为"+dengLuCustomer.getBalance());
}else {
System.out.println("---------------取钱失败---------------");
}
}
/**
* 修改用户密码
* @param dengLuCustomer
*/
public void updaterCustomerPsd(Customer dengLuCustomer) {
/*
* 1.修改密码前先输入自身密码才可进行修改;
* 2.获取用户两次输入的密码;
* 3.判断两次输入的密码是否一致;
* 如果两次输入的密码不一致,重新输入;
* 若两次输入的密码一致,提示修改成功;
*
*/
boolean isSuccess = true;
String psd = null;
String userPsd = null;
while(isSuccess) {
//1.修改密码前先输入自身密码才可进行修改;
System.out.println("请输入你的密码:");
psd = bkUtils.getReadString();
userPsd = dengLuCustomer.getPassword();
if(psd.equals(userPsd)) {
//2.获取用户两次输入的密码;
boolean isflag = true;
String psd1 = null;
String psd2 = null;
while(isflag) {
System.out.println("请输入你需要修改的密码:");
psd1 = bkUtils.getReadString();
//判断输入的密码是否为空
if(psd1.length() == 0 || psd1 == null) {
System.out.println("输入的密码不能为空!!!");
break;
}
System.out.println("请再一次输入你需要修改的密码:");
psd2 = bkUtils.getReadString();
//判断输入的密码是否为空
if(psd2.length() == 0 || psd2 == null) {
System.out.println("输入的密码不能为空!!!");
break;
}
/*
* 3.判断两次输入的密码是否一致;
* 如果两次输入的密码不一致,重新输入;
* 若两次输入的密码一致,提示修改成功;
*/
if(psd1.equals(psd2)) {
userPsd = psd2;
dengLuCustomer.setPassword(psd2);
isflag = false;
isSuccess = false;
System.out.println("---------------密码修改成功,你的新密码是:"+dengLuCustomer.getPassword()+",请牢记---------------");
return;
}else {
System.out.println("---------------密码修改失败---------------");
}
}
}else {
System.out.println("你输入的密码错误,请重新输入!!!");
}
}
}
public void displayCustomer(Customer customer) {
System.out.println("用户名\t\t\t用户账号\t用户密码\t用户余额\t用户手机号");
String name = customer.getName();//用户
String account = customer.getAccount();//用户账号
String password = customer.getPassword();//用户密码
double balance = customer.getBalance(); //用户余额
String phone = customer.getPhone(); //用户手机号
System.out.println(name + "\t\t" + account + "\t\t" + password + "\t\t" + balance + "\t\t" + phone );
System.out.println();
}
}
模拟数据库
package com.lll.bank;
import com.lll.bank.Admin;
import com.lll.bank.Customer;
public class DataBase {
//定义一个数组存储管理员信息
private Admin [] admins = new Admin[3];
//定义一个数组存储用户信息
private Customer [] customers = new Customer[10];
//定义获取管理Admin信息的get/set方法
public Admin[] getAdmins() {
return admins;
}
public void setAdmins(Admin[] admins) {
this.admins = admins;
}
//定义获取用户Customer信息的get/set方法
public Customer[] getCustomers() {
return customers;
}
public void setCustomers(Customer[] customers) {
this.customers = customers;
}
//模拟存储的管理员信息
public Admin[] getAdmin() {
for(int x = 1 ; x <= admins.length ; x++) {
admins[x - 1]= new Admin("admin0"+x,"abc"+x);
}
return admins;
}
//模拟存储的用户信息
public Customer[] getCostomer() {
for(int x = 1 ; x <= customers.length ; x++) {
customers[x - 1]= new Customer("customerName0"+x,"user0"+x,"abcde"+x,10000,"11122233"+x);
}
return customers;
}
}