欢迎来到天天文库
浏览记录
ID:55272754
大小:54.00 KB
页数:17页
时间:2020-05-08
《银行管理系统JAVA.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、1)Account.java类packagecom.etp;importjava.util.*;publicabstractclassAccount{protectedlongid;protectedStringpassword;protectedStringname;protectedStringpersonId;protectedStringemail;protecteddoublebalance;@Overridepublicbooleanequals(Objectobj){booleanrt=false;if(this==obj)r
2、t=true;if(objinstanceofAccount){AccountanotherAcc=(Account)obj;if(this.id==anotherAcc.id)rt=true;}returnrt;}@OverridepublicinthashCode(){returnpassword.hashCode()+name.hashCode()+personId.hashCode()+email.hashCode();}@OverridepublicStringtoString(){returnid+";"+password+";
3、"+name+";"+personId+";"+email+";"+balance;}/**无参构造体*/publicAccount(){}/**有参构造体,用于初始化对象的必要属性*/publicAccount(longid,Stringpassword,Stringname,StringpersonId,Stringemail,doublebalance){this.setId(id);this.setPassword(password);this.setName(name);this.setPersonId(personId);thi
4、s.setEmail(email);this.setBalance(balance);}/**存款方法*/publicvoiddeposit(doublemoney){balance+=money;}/**取款方法,抽象类,行为不确定,有储蓄账户和信用账户之分*@throwsBalanceNotEnoughException*/publicabstractvoidwithdraw(doublemoney)throwsBalanceNotEnoughException;/**属性的封装*/publicvoidsetId(longid){thi
5、s.id=id;}publiclonggetId(){returnid;}publicvoidsetPassword(Stringpassword){this.password=password;}publicStringgetPassword(){returnpassword;}publicvoidsetName(Stringname){this.name=name;}publicStringgetName(){returnname;}publicvoidsetPersonId(StringpersonId){this.personId=
6、personId;}publicStringgetPersonId(){returnpersonId;}publicvoidsetEmail(Stringemail){this.email=email;}publicStringgetEmail(){returnemail;}publicvoidsetBalance(doublebalance){this.balance=balance;}publicdoublegetBalance(){returnbalance;}}2)ATM.java类packagecom.etp;importjava
7、.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服
8、务系统");System.out.println("****************");System.out.println("1.登录");System.out.printl
此文档下载收益归作者所有