银行管理系统JAVA.doc
- 文档编号:343720
- 上传时间:2022-10-09
- 格式:DOC
- 页数:17
- 大小:54KB
银行管理系统JAVA.doc
《银行管理系统JAVA.doc》由会员分享,可在线阅读,更多相关《银行管理系统JAVA.doc(17页珍藏版)》请在冰豆网上搜索。
1)Account.java类
packagecom.etp;
importjava.util.*;
publicabstractclassAccount{
protectedlongid;
protectedStringpassword;
protectedStringname;
protectedStringpersonId;
protectedStringemail;
protecteddoublebalance;
@Override
publicbooleanequals(Objectobj){
booleanrt=false;
if(this==obj)
rt=true;
if(objinstanceofAccount)
{
AccountanotherAcc=(Account)obj;
if(this.id==anotherAcc.id)
rt=true;
}
returnrt;
}
@Override
publicinthashCode(){
returnpassword.hashCode()+name.hashCode()+personId.hashCode()+email.hashCode();
}
@Override
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类
packagecom.etp;
importjava.util.*;
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服务系统");
System.out.println("****************");
System.out.println("1.登录");
System.out.println("2.开户");
System.out.println("0.退出");
System.out.println("****************");
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;
break;
case0:
rt=false;
outflag=false;
break;
default:
break;
}
}while(rt);
}while(outflag);
System.out.println("谢谢您的使用!
");
}
/**登录成功后的二级菜单*/
privatevoidsecondMenu(){
Scannerscanner=newScanner(System.in);
Accountaccount=null;
out:
do
try{
/*输入卡号,输入exit可以直接退出系统*/
System.out.print("输入卡号:
");
StringcardNo0;
longcardNo;
out1:
do{
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可以直接退出系统*/
System.out.print("密码:
");
Stringpassword=scanner.next();
if(password.equals("exit")||password.equals("EXIT")){
breakout;
}
account=bank.login(cardNo,password);
breakout;
}catch(LoginExceptione){
System.out.println(e.toString());
}
while(true);
if(account!
=null){
out:
do{
System.out.println("ATM操作界面");
System.out.println("****************");
System.out.println("1.存款操作");
System.out.println("2.取款操作");
System.out.println("3.查询余额");
System.out.println("4.设置透支额度");
System.out.println("5.统计银行总余额");
System.out.println("6.查询本人信息");
System.out.println("0.退出");
System.out.println("****************");
System.out.print("请选择操作:
");
scanner=newScanner(System.in);
Stringsc;
do{
sc
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 银行 管理 系统 JAVA