银行管理系统JAVAWord文件下载.doc
《银行管理系统JAVAWord文件下载.doc》由会员分享,可在线阅读,更多相关《银行管理系统JAVAWord文件下载.doc(17页珍藏版)》请在冰豆网上搜索。
AccountanotherAcc=(Account)obj;
if(this.id==anotherAcc.id)
rt=true;
}
returnrt;
}
publicinthashCode(){
returnpassword.hashCode()+name.hashCode()+personId.hashCode()+email.hashCode();
publicStringtoString(){
returnid+"
;
"
+password+"
+name+"
+personId+"
+email+"
+balance;
/**无参构造体*/
publicAccount(){
/**有参构造体,用于初始化对象的必要属性*/
publicAccount(longid,Stringpassword,Stringname,StringpersonId,
Stringemail,doublebalance)
{
this.setId(id);
this.setPassword(password);
this.setName(name);
this.setPersonId(personId);
this.setEmail(email);
this.setBalance(balance);
/**存款方法*/
publicvoiddeposit(doublemoney){
balance+=money;
/**取款方法,抽象类,行为不确定,有储蓄账户和信用账户之分
*@throwsBalanceNotEnoughException*/
publicabstractvoidwithdraw(doublemoney)throwsBalanceNotEnoughException;
/**属性的封装*/
publicvoidsetId(longid){
this.id=id;
publiclonggetId(){
returnid;
publicvoidsetPassword(Stringpassword){
this.password=password;
publicStringgetPassword(){
returnpassword;
publicvoidsetName(Stringname){
this.name=name;
publicStringgetName(){
returnname;
publicvoidsetPersonId(StringpersonId){
this.personId=personId;
publicStringgetPersonId(){
returnpersonId;
publicvoidsetEmail(Stringemail){
this.email=email;
publicStringgetEmail(){
returnemail;
publicvoidsetBalance(doublebalance){
this.balance=balance;
publicdoublegetBalance(){
returnbalance;
}
2)ATM.java类
importjava.io.*;
publicclassATM{
privateBankbank;
publicATM(){
/*初始化Bank类,此时调用Bank的构造函数,其中默认的两个测试用户的信息被添加到Account类中*/
bank=newBank();
publicstaticvoidmain(String[]args){
ATMatm=newATM();
atm.mainMenu();
privatevoidmainMenu(){
booleanoutflag=true;
do{
System.out.println("
ATM服务系统"
);
****************"
1.登录"
2.开户"
0.退出"
System.out.print("
请选择操作:
Scannerscanner=newScanner(System.in);
StringfirstChoice;
do{
firstChoice=scanner.next();
if(firstChoice.matches("
^[0-2]$"
)){
break;
}else
System.out.println("
选择输入错误!
}while(true);
booleanrt=true;
out:
do{
switch(Integer.parseInt(firstChoice)){
case1:
/*进入登录界面或登录成功界面*/
secondMenu();
breakout;
case2:
/*开户,捕捉createAccount方法抛出的所有异常*/
try{
bank.createAccount();
}catch(RegisterExceptione){
System.out.println(e.toString());
}
rt=false;
case0:
outflag=false;
default:
}
}while(rt);
}while(outflag);
System.out.println("
谢谢您的使用!
/**登录成功后的二级菜单*/
privatevoidsecondMenu(){
Scannerscanner=newScanner(System.in);
Accountaccount=null;
out:
do
try{
/*输入卡号,输入exit可以直接退出系统*/
System.out.print("
输入卡号:
StringcardNo0;
longcardNo;
out1:
cardNo0=scanner.next();
if(cardNo0.equals("
exit"
)||cardNo0.equals("
EXIT"
breakout;
}elseif(cardNo0.matches("
^[0-9_]+$"
cardNo=Long.parseLong(cardNo0);
breakout1;
}else
System.out.println("
请输入数字类型的ID!
}while(true);
/*输入密码,输入exit可以直接退出系统*/
密码:
Stringpassword=scanner.next();
if(password.equals("
)||password.equals("
account=bank.login(cardNo,password);
breakout;
}catch(LoginExceptione){
System.out.println(e.toString());
}
while(true);
if(account!
=null){
System.out.println("
ATM操作界面"
1.存款操作"
2.取款操作"
3.查询余额"
4.设置透支额度"
5.统计银行总余额"
6.查询本人信息"
0.退出"
scanner=newScanner(System.in);
Stringsc;
do{
sc