1 packageKaoshi;2
3 /*信1705-3 20173442 田昕可*/
4 import java.util.*;5 import java.io.*;6
7 classAccount8 {9 privateString accountID;10 privateString accountname;11 private String operatedate;//时间
12 private int operatetype;//操作
13 private String accountpassword;//密码
14 private int accountbalance;//余额
15 private int amout;//流水金额
16
17 public Account(String accid,String accna,String opeda,String password,intbalance)18 {19 this.accountID=accid;20 this.accountname=accna;21 this.operatedate=opeda;22 this.accountpassword=password;23 this.accountbalance=balance;24 }25
26 publicString getaccountID()27 {28 returnaccountID;29 }30 publicString getaccountname()31 {32 returnaccountname;33 }34 publicString getoperatedate()35 {36 returnoperatedate;37 }38 public intgetoperatetype()39 {40 returnoperatetype;41 }42 publicString getaccountpassword()43 {44 returnaccountpassword;45 }46 public intgetaccountbalance()47 {48 returnaccountbalance;49 }50 public intgetamout()51 {52 returnamout;53 }54 public voidsetaccountID(String accid)55 {56 accountID=accid;57 }58 public voidsetaccountname(String accna)59 {60 accountname=accna;61 }62 public voidsetoperatedate(String opeda)63 {64 operatedate=opeda;65 }66 public void setoperatetype(intopety)67 {68 operatetype=opety;69 }70 public voidsetaccountpassword(String password)71 {72 accountpassword=password;73 }74 public void setaccountbalance(intbalance)75 {76 accountbalance=balance;77 }78 public void setamout(intamo)79 {80 amout=amo;81 }82
83 public voidjiemian()84 {85 System.out.println("**************************************************************************");86 System.out.println(" 欢迎"+accountID+"使用中国工商银行自助柜员系统 ");87 System.out.println("**************************************************************************");88 }89
90 public voidcaozuo()91 {92 Scanner scan1=newScanner(System.in);93 inta;94 intb;95 intc;96 String s;97 String s1;98 switch(operatetype)99 {100 case 1:System.out.println("请输入存款金额 : ");101 a=scan1.nextInt();102 accountbalance+=a;103 System.out.println("存取款操作完成");104 System.out.println("存款余额为 :"+accountbalance);105 //差一个try语句;
106 break;107 case 2:System.out.println("当前账户每日可支取2万");108 System.out.println("1.100");109 System.out.println("2.500");110 System.out.println("3.1000");111 System.out.println("4.1500");112 System.out.println("5.2000");113 System.out.println("6.5000");114 System.out.println("7.其他金额");115 b=scan1.nextInt();116 switch(b)117 {118 case 1:accountbalance-=100;break;119 case 2:accountbalance-=500;break;120 case 3:accountbalance-=1000;break;121 case 4:accountbalance-=1500;break;122 case 5:accountbalance-=2000;break;123 case 6:accountbalance-=5000;break;124 case 7:System.out.println("输入金额 :");c=scan1.nextInt();accountbalance-=c;break;125 };126 System.out.println("取取款操作完成");127 System.out.println("存款余额为 :"+accountbalance);128 break;129 case 3:break;130 case 4:131 System.out.println("请输入修改后的密码");132 s1=scan1.nextLine();133 accountpassword=s1;//修改密码
134 System.out.println("修改成功,当前密码为"+accountpassword);135 case 5:System.out.println("当前账户余额为:"+accountbalance);136 }137
138 }//六项操作
139
140 }141 public classXixiguanli {142
143 public static voidmain(String[] args) {144 //TODO Auto-generated method stub
145 File file1 = new File("accountlist.txt");146 File file2 = new File("accountinformation.txt");147 inti;148 int j=0;149 int t=0;150 intb;151 String c;152 System.out.println("**************************************************************************");153 System.out.println(" 欢迎使用中国工商银行自动柜员系统 ");154 System.out.println("**************************************************************************");155
156 Account[] a = new Account[5];157 Account s1=new Account("20173442","田昕可","2018-9-20","123456",0);158 Account s2=new Account("00000001","张","2018-9-20","123456",0);159 Account s3=new Account("00000002","王","2018-9-20","123456",0);160 Account s4=new Account("00000003","李","2018-9-20","123456",0);161 Account s5=new Account("00000004","赵","2018-9-20","123456",0);162 a[0]=s1;163 a[1]=s2;164 a[2]=s3;165 a[3]=s4;166 a[4]=s5;167 System.out.println(" 请输入您的账号");168
169 String id;170 String password;171 Scanner scan=newScanner(System.in);172 id=scan.next();173 for(i=0;i<5;i++)174 {175 if(id==a[i].getaccountID())176 j=i;177 }178 /*while(id.length()!=8||j==6);179 {180 if(id.length()!=8)181 System.out.println("不是工行号,请重新输入");182 else if(j==6)183 System.out.println("该账号不存在,请重新输入");184 System.out.println("请输入您的账号");185 id=scan.next();186 }*/
187
188 a[j].jiemian();189 System.out.println(" 请输入密码");190 password=scan.next();191 /*if(a[j].getaccountpassword() equals password)192 {193 System.out.println("密码正确");194 a[j].jiemian();195 System.out.println("1.存款");196 System.out.println("2.取款");197 System.out.println("3.转账汇款");198 System.out.println("4.修改密码");199 System.out.println("5.查询余额");200 }*/
201 a[j].jiemian();202 System.out.println("1.存款");203 System.out.println("2.取款");204 System.out.println("3.转账汇款");205 System.out.println("4.修改密码");206 System.out.println("5.查询余额");207 System.out.println("6.退出");208 System.out.println("请输入要实现的功能 :");209 b=scan.nextInt();210 while(b!=6)211 {212 a[j].setoperatetype(b);//将操作数字赋值给类成员
213 /*if(b==3)214 {215 System.out.println("请输入转账账户");216 c=scan.nextLine();217 for(i=0;i<5;i++)218 {219 if()220 }221 }//类外函数不能实现的转账功能*/
222 a[j].caozuo();223 a[j].jiemian();224 System.out.println("1.存款");225 System.out.println("2.取款");226 System.out.println("3.转账汇款");227 System.out.println("4.修改密码");228 System.out.println("5.查询余额");229 System.out.println("请输入要实现的功能 :");230 b=scan.nextInt();231 }232
233 }