废话不多说,直接上代码
public class BankSysMethod {
// NEW新的Xustomer类并存储在里面
Customer cust = new Customer();
//通过switch语句实现管理员功能
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("查看:用户");
break;//查看后直接Break结束循环
case 2:
//修改用户信息
System.out.println("修改:用户信息");
break;同上
case 3:
//增加:用户
System.out.println("增加:用户");
//Customer[] newCustomers = cust.addCustomer(customer);
//这里的查询用户传进的是 Customer[] customer ,所以需要把扩容后添加进新用户的数组赋值给customer里;
//customer = 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(customer);
//这里的查询用户传进的是Customer[] customer ,所以需要把减容后的新用户的数组赋值给customer;
//customer = deleteCustomer;
break;
case 5:
isExit = false;
break;
default:
System.out.println("系统操作错误!!!");
break;
}
}
//return customer;
}
BankUtils bkUtils = new BankUtils() ;
//存储登录的管理员
Admin admin = null ;
//此方法用于管理员登陆,整合了账号,密码验证方法
public Admin sysRootDengLu(Admin [] admins) {
for(int x = 1 ; x <= 3 ; x++) {
//获取输入的管理员账号
System.out.println("请输入管理员账号:(这里无需输入字符)");
String account = bkUtils.getReadString();//admin01
//获取输入的管理员密码
System.out.println("请输入管理员密码:同上");
@SuppressWarnings("unused")
String psd = bkUtils.getReadString();
//verificatAccount :存储账号
//verificatPsd:存储密码
// 循环遍历所有管理员的账号,密码;
// 如果输入的管理员账号存在,则用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与输入的密码比较:则说明输入的管理员密码不存在,显示该管理员密码错误提示
if(verificatAccount == null) {
System.out.println("该管理员账号不存在!!!你还有"+(10-x)+"次机会!");
}else if(!psd.equals(verificatPsd)) {
System.out.println("管理员密码错误!!!你还有"+(5-x)+"次机会!");
}else if(verificatAccount != null && verificatPsd != null) {
System.out.println("登陆成功");
return admin;
}
//登陆失败只限10次,10次之后冻结
if((10-x) == 0) {
System.out.println("你已被冻结");
}
}
return null;
}
}
//此代码用于实现管理员的登录 查找 删除 增加 修改 是Bank中核心代码类之一

本文介绍了一个银行系统的管理模块实现方式,主要包括用户信息的增删改查功能,并详细展示了通过switch语句来实现不同操作的流程。同时,还提供了管理员登录验证的逻辑实现。
1664

被折叠的 条评论
为什么被折叠?



