资源描述:
《基于JAVA的ATM模拟系统.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、使用JAVA设计一个ATM程序,实现自动取款机存款、取款、查询等功能。程序:(1)【Account】packageatm;/***账户类:包含两种账户类型-->1.储蓄账户2.信用账户*/publicabstractclassAccount{//属性protectedlongid;protectedStringpassword;protectedStringname;protectedStringIDcardid;protectedintaccountType;protecteddoublebalance;//构造方法publicAccoun
2、t(){super();}publicAccount(longid,Stringpassword,Stringname,StringIDcardid,intaccoutType,doublebalance){super();this.id=id;this.password=password;this.name=name;this.IDcardid=IDcardid;this.accountType=accountType;this.balance=balance;}//getXxx,setXxx方法publiclonggetId(){retu
3、rnid;}publicvoidsetId(longid){this.id=id;}publicStringgetPassword(){returnpassword;}publicvoidsetPassword(Stringpassword){this.password=password;}publicStringgetName(){returnname;}publicvoidsetName(Stringname){this.name=name;}publicStringgetIDcardid(){returnIDcardid;}public
4、voidsetIDcardid(StringIDcardid){this.IDcardid=IDcardid;}publicintgetAccountType(){returnaccountType;}publicvoidsetAccountType(intaccountType){this.accountType=accountType;}publicdoublegetBalance(){returnbalance;}publicvoidsetBalance(doublebalance){this.balance=balance;}/***
5、存款*/publicvoiddeposit(doublemoney){balance+=money;}/***取款(取款方式由账户类型决定,所以设为抽象方法,相应的Account类应设为抽象类)*/publicabstractvoidfetchMoney(doublemoney);}(2)【SavingAccount】packageatm;/***储蓄账户类*/publicclassSavingAccountextendsAccount{//构造函数publicSavingAccount(){super();}publicSavingAcco
6、unt(longid,Stringpassword,Stringname,StringIDcardid,intaccountType,doublebalance){super(id,password,name,IDcardid,accountType,balance);}//对父类的fetchMoney()实现publicvoidfetchMoney(doublemoney){if(balance7、itAccount】packageatm;/***信用账户类,增加一个信用额度ceiling属性*/publicclassCreditAccountextendsAccount{privateintceiling;//构造函数publicCreditAccount(){super();}publicCreditAccount(longid,Stringpassword,Stringname,StringIDcardid,intaccountType,doublebalance,intceiling){super(id,password,nam
8、e,IDcardid,accountType,balance);this.ceiling=ceiling;}//getXxx,setXxx方法publicintge