每日总结
今天完善ATM系统的功能。
完整代码如下:
package ATMDemo;
import java.util.Scanner;
public class AccountManager {
Account ab=new Account();
Account[] ai=new Account[5];
public void zhaohaoboshuodefangfa() {
ai[0]=new Account("20193937","李兴宇","111222",0);
ai[1]=new Account("20193938","张三","222333",0);
ai[2]=new Account("20193939","李四","333444",0);
ai[3]=new Account("20193940","王五","444555",0);
ai[4]=new Account("20193941","刘一","555666",0);
}
public void zhanghao() {
//Account at1=new Account("null","null","null",)
while(true) {
for(int i=0;i<40;i++) {
System.out.print("*");
}
System.out.println();
System.out.println(" 欢迎使用中国工商银行自动柜员系统 ");
for(int i=0;i<40;i++) {
System.out.print("*");
}
System.out.println();
Scanner sc=new Scanner(System.in);
System.out.println("请输入您的帐号:");
String id=sc.nextLine();
if(id.length()!=8) {
System.out.println("该卡不是工行卡");
continue;
}
int i;
int index=-1;
for(i=0;i<ai.length;i++) {
if(ai[i].getAccountID().equals(id)) {
index=i;
ab=ai[index];
}
}
if(index==-1&&id.length()==8) {
System.out.println("该账号不存在");
}if(index!=-1&&id.length()==8) {
AccountManager acc=new AccountManager();
acc.mima();
}
}
}
public void mima() {
int counter=0;
while(true) {
for(int j=0;j<40;j++) {
System.out.print("*");
}
System.out.println();
System.out.println(" 欢迎"+ab.getAccountname()+"使用中国工商银行自助柜员系统 ");
for(int j=0;j<40;j++) {
System.out.print("*");
}
System.out.println();
Scanner mc=new Scanner(System.in);
System.out.println("请输入您的密码:");
String mi=mc.nextLine();
if(mi.length()!=6&&counter!=3) {
System.out.println("密码录入错误");
counter++;
continue;
}
int index=-1;
if(ab.getAccountpassword().equals(mi)) {
index=1;
}
if(index==-1&&mi.length()==6&&counter!=3) {
System.out.println("密码录入错误");
counter++;
}
if(counter==3) {
System.out.println("该账号三次录入密码错误,该卡已被系统没收,请与工行及时联系处理");
AccountManager acc=new AccountManager();
acc.zhanghao();
}
if(index!=-1&&counter!=3) {
break;
}
}
}
public void zhujiemian() {
Scanner sc=new Scanner(System.in);
for(int j=0;j<40;j++) {
System.out.print("*");
}
System.out.println("欢迎"+ab.getAccountname()+"使用中国工商银行自助柜员系统");
for(int j=0;j<40;j++) {
System.out.print("*");
}
System.out.println("1、存款");
System.out.println("2、取款");
System.out.println("3、转账汇款");
System.out.println("4、修改密码");
System.out.println("5、查询余额");
for(int j=0;j<40;j++) {
System.out.print("*");
}
int select=sc.nextInt();
switch(select) {
case 1:
cunkuan();
break;
case 2:
qukuan();
break;
case 3:
zhuanzhang();
break;
case 4:
chanxun();
break;
}
}
public static void main(String[] args) {
AccountManager acc=new AccountManager();
acc.zhanghao();
}
}