『壹』 奼傦細鐢↗AVA璇璦緙栧啓鐨勯摱琛屽剁畻娉曠殑婧愪唬鐮
import java.util.*;
class ThreadTest {
static int type = 4, num = 10; //瀹氫箟璧勬簮鏁扮洰鍜岀嚎紼嬫暟鐩
static int[] resource = new int[type]; //緋葷粺璧勬簮鎬繪暟
//static int[] Resource = new int[type]; //鍓鏈
static Random rand = new Random();
static Bank[] bank = new Bank[num]; //綰跨▼緇
Bank temp = new Bank();
public void init() {
//鍒濆嬪寲緇勪腑姣忎釜綰跨▼錛岄殢鏈哄~鍏呯郴緇熻祫婧愭繪暟
for(int i = 0; i < type; i++)
resource[i] = rand.nextInt(10) + 80;
System.out.print("Resource:");
for(int i = 0; i < type; i++)
System.out.print(" " + resource[i]);
System.out.println("");
for(int i = 0; i < bank.length; i++)
bank[i] = new Bank("#" + i);
}
public ThreadTest4() {
init();
}
class Bank extends Thread {
//閾惰屽剁畻娉曢伩鍏嶆婚攣
public int[]
max = new int[type], //鎬誨叡闇奼傞噺
need = new int[type], //灝氶渶璧勬簮閲
allocation = new int[type]; //宸插垎閰嶉噺
private int[]
request = new int[type], //鐢寵瘋祫婧愰噺
Resource = new int[type]; //璧勬簮鍓鏈
private boolean isFinish = false; //綰跨▼鏄鍚﹀畬鎴
int[][] table = new int[bank.length][type*4]; //浜岀淮璧勬簮鍒嗛厤琛
private void init() {
// 闅忔満濉鍏呮誨叡銆佸皻闇銆佸凡鍒嗛厤閲
synchronized(resource) {
for(int i = 0; i < type; i++) {
max[i] = rand.nextInt(5) + 10;
need[i] = rand.nextInt(10);
allocation[i] = max[i] - need[i];
resource[i] -= allocation[i]; //浠庣郴緇熻祫婧愪腑鍑忓幓宸插垎閰嶇殑
}
printer();
for(int i = 0; i < type; i++) {
if(resource[i] < 0) {
//鑻ュ嚭鐜板凡鍒嗛厤閲忚秴鍑虹郴緇熻祫婧愭繪暟鐨勯敊璇鍒欓鍑
System.out.println("The summation of Threads' allocations is out of range!");
System.exit(1);
}
}
}
}
public Bank(String s) {
setName(s);
init();
start();
}
public Bank() {
//none
}
public void run() {
try {
sleep(rand.nextInt(2000));
}
catch(InterruptedException e) {
throw new RuntimeException(e);
}
while(true) {
//紼嬪簭娌℃湁瀹屾垚鏃朵竴鐩翠笉鏂鐢寵瘋祫婧
if(askFor() == false) {
try {
sleep(1000);
}
catch(InterruptedException e) {
throw new RuntimeException(e);
}
}
else
tryRequest();
if(noNeed() == true)
break;
}
//浼戠湢涓孌墊椂闂存ā鎷熺▼搴忚繍琛
try {
sleep(1000);
}
catch(InterruptedException e) {
throw new RuntimeException(e);
}
System.out.println(getName() + " finish!");
synchronized(resource) {
//榪愯岀粨鏉熼噴鏀懼崰鏈夎祫婧
for(int i = 0; i < type; i++) {
resource[i] += allocation[i];
need[i] = allocation[i] = max[i] = 0;
}
}
}
private void printer() {
//鎵撳嵃褰撳墠璧勬簮淇℃伅
System.out.print(getName() + " Max:");
for(int i = 0; i < type; i++)
System.out.print(" " + max[i]);
System.out.print(" Allocation:");
for(int i = 0; i < type; i++)
System.out.print(" " + allocation[i]);
System.out.print(" Need:");
for(int i = 0; i < type; i++)
System.out.print(" " + need[i]);
System.out.print(" Available:");
for(int i = 0; i < type; i++)
System.out.print(" " + resource[i]);
System.out.println("");
}
private boolean askFor() {
//闅忔満浜х敓鐢寵瘋祫婧愰噺騫舵嫻嬫槸鍚﹁秴鏍
boolean canAsk = false;
for(int i = 0; i < type; i++) {
request[i] = rand.nextInt(20);
//闃叉㈢敵璇烽噺瓚呰繃鎵闇閲
if(request[i] > need[i])
request[i] = need[i];
}
for(int i = 0; i < type; i++) //闃叉㈤殢鏈虹敵璇瘋祫婧愬叏涓0
if(request[i] > 0)
canAsk = true;
synchronized(resource) {
//閿佷綇鍙渚涜祫婧愭鏌ユ槸鍚﹁秴鏍
for(int i = 0; i < type; i++) {
if(request[i] > resource[i])
//濡傛灉鐢寵瘋祫婧愯秴榪囧彲渚涜祫婧愬垯絳夊緟涓孌墊椂闂村悗閲嶆柊鐢寵
return false;
}
}
return canAsk;
}
private void tryRequest() {
//鍒涘緩鍓鏈灝濊瘯鍒嗛厤璇鋒眰
synchronized(resource) {
for(int i = 0; i < type; i++)
//渚濈劧瑕侀槻姝㈣鋒眰閲忚秴鍑鴻寖鍥
if(request[i] > resource[i])
return;
for(int i = 0; i < type; i++) {
//澶嶅埗璧勬簮閲忓苟鍑忓幓闇奼傞噺鍒頒竴涓鍓鏈涓
Resource[i] = resource[i];
Resource[i] -= request[i];
}
System.out.print(getName() + " ask for:");
for(int i = 0; i < type; i++)
System.out.print(" " + request[i]);
System.out.println("");
if(checkSafe() == true) {
//濡傛灉媯鏌ュ畨鍏ㄥ垯灝嗗壇鏈鍊艱祴緇欒祫婧愰噺騫朵慨鏀瑰崰鏈夐噺鍜岄渶奼傞噺
for(int i = 0; i < type; i++) {
resource[i] = Resource[i];
allocation[i] += request[i];
need[i] -= request[i];
}
System.out.println(getName() + " request succeed!");
}
else
System.out.println(getName() + " request fail!");
}
}
private boolean checkSafe() {
//閾惰屽剁畻娉曟鏌ュ畨鍏ㄦ
synchronized(bank) {
//灝嗙嚎紼嬭祫婧愪俊鎮鏀懼叆浜岀淮璧勬簮鍒嗛厤琛ㄦ鏌ュ畨鍏ㄦэ紝0~type鍙鐢ㄨ祫婧愶紡type~type*2鎵闇璧勬簮錛弔ype*2~type*3鍗犳湁璧勬簮錛弔ype*3~-1鍙鐢+鍗犵敤璧勬簮
for(int i = 0; i < bank.length; i++) {
for(int j = type; j < type*2; j++) {
table[i][j] = bank[i].need[j%type];
}
for(int j = type*2; j < type*3; j++) {
table[i][j] = bank[i].allocation[j%type];
}
}
//鍐掓場鎺掑簭鎸夐渶奼傝祫婧愪粠灝忓埌澶ф帓
for(int i = 0; i < bank.length; i++) {
for(int j = i; j < bank.length-1; j++) {
sort(j, 4);
}
}
//榪涜屾ゆ椂鍒葷殑瀹夊叏鎬ф鏌
for(int i = 0; i < type; i++) {
table[0][i] = Resource[i];
table[0][i+type*3] = table[0][i] + table[0][i+type*2];
if(table[0][i+type*3] < table[1][i+type])
return false;
}
for(int j = 1; j < bank.length-1; j++) {
for(int k = 0; k < type; k++) {
table[j][k] = table[j-1][k+type*3];
table[j][k+type*3] = table[j][k] + table[j][k+type*2];
if(table[j][k+type*3] < table[j+1][k+type])
return false;
}
}
}
return true;
}
private void sort(int j, int k) {
//閫掑綊鍐掓場鎺掑簭
int tempNum;
if(table[j][k] > table[j+1][k]) {
for(int i = type; i < type*2; i++) {
tempNum = table[j][i];
table[j][i] = table[j+1][i];
table[j+1][i] = tempNum;
}
/*temp = bank[j];
bank[j] = bank[j+1];
bank[j+1] = temp;*/
}
else if(table[j][k] == table[j+1][k] && k < type*2) //姝よ祫婧愰噺鐩稿悓鏃墮掑綊涓嬩竴涓璧勬簮閲忔帓搴忓苟涓旈槻姝㈣秴鍑鴻寖鍥
sort(j, k+1);
}
private boolean noNeed() {
//鏄鍚﹁繕闇瑕佽祫婧
boolean finish = true;
for(int i = 0; i < type; i++) {
if(need[i] != 0) {
finish = false;
break;
}
}
return finish;
}
}
public static void main(String[] args) {
ThreadTest t = new ThreadTest();
//鍚庡彴綰跨▼錛岃懼畾紼嬪簭榪愯屽氶暱鏃墮棿鍚庤嚜鍔ㄧ粨鏉
new Timeout(30000, "---Stop!!!---");
}
}
『貳』 求一個JSP 網路銀行或者ATM源代碼
import java.util.Scanner;
import java.util.Date;
public class ATM {
public static void main (String[] args) {
System.out.println("您好,歡迎使用農業銀行優惠卡!");
int a=123456;
int jine;
int flag=0,bianhao=1023;
int mima;
int anjian;
int ye=0;
int xianshi,dayin;
int year,month,date;
String zhanghao="6228480270673875612",zhuanzhanghao;
Scanner sc=new Scanner(System.in);
for(int i=1;i<=3;i++){
System.out.println("請輸入密碼:(6位數字)");
mima=sc.nextInt();
if(a==mima)
{
System.out.println ("密碼正確請選擇業務");
for(;;){
System.out.println ("取款\t~1~");
System.out.println ("轉賬\t~2~");
System.out.println ("存現\t~3~");
System.out.println ("更改密碼~4~");
System.out.println ("查詢余額~5~");
System.out.println ("取卡\t~0~");
anjian=sc.nextInt();
if(anjian==1)
{
if(ye<100)
{
System.out.println ("您的余額不足100元,請您及時存現");
break;
}
int qukuan;
for(;;)
{
for(;;)
{
System.out.println ("---------------取款功能--------------");
System.out.println ("請輸入您要取款的份額:");
System.out.println ("\t100\t200\t500\t");
qukuan=sc.nextInt();
if(qukuan<=ye)
{
break;
}
else{
System.out.println ("余額不足,取消交易");
}
}if(qukuan==100||qukuan==200||qukuan==500)
{
break;
}
else
{
System.out.println ("您的輸入有誤請輸入正百的數");
}
}
ye-=qukuan;
System.out.println ("交易正在處理~請稍候~z~z~z~z~z~z~z~~~~~~~");
System.out.println ("請您收好您的"+qukuan+"元"+"鈔票----15秒鍾自動收回");
System.out.println ("-----------------------------------------------------");
System.out.println ("是否顯示余額?顯示:1不顯示:2");
xianshi=sc.nextInt();
if(xianshi==1)
{
System.out.println ("您的余額為"+ye+"元");
System.out.println ("--------------------------------");
System.out.println ("為了您和您家人的幸福,請節約用錢");
System.out.println ("--------------------------------");
}
System.out.println ("是否列印取款憑條?列印:1 不列印:2");
dayin=sc.nextInt();
Date dd=new Date();
if(dayin==1)
{
System.out.println ("-----------------------中國農業銀行-------------------------");
System.out.println ("\t\t\t----------取款憑條-----------\t\t\t");
System.out.println ("帳號:"+zhanghao);
System.out.println ("取款份額:"+qukuan);
System.out.println ("余額:"+ye);
System.out.println ("日期:"+dd.toLocaleString());
System.out.println ("------------------------------------------------------------");
System.out.println ("\t\t\t機器編號:"+bianhao);
System.out.println ("------------------------------------------------------------");
}
int ji;
System.out.println ("是否繼續業務:繼續:1 取卡:2");
ji=sc.nextInt();
if(ji==1)
{
continue;
}
if(ji==2)
{
System.out.println ("請收回您的磁卡,下次再見");
break;
}
}
if(anjian==2)
{
int zhuanzhang;
for(;;)
{
System.out.println ("---------------轉賬功能----------------");
System.out.println ("請輸入您要轉賬的份額:");
zhuanzhang=sc.nextInt();
if(zhuanzhang%100==0)
{
if(ye-zhuanzhang>=00)
{
break;
}
else
{
System.out.println ("余額不足,請重新輸入");
}
}
else
{
System.out.println ("您的輸入無效");
}
}
for(;;)
{
System.out.println ("請輸入您要轉賬的賬號:(19位)");
zhuanzhanghao=sc.next();
if(zhuanzhanghao.length()==19)
{
break;
}
else
{
System.out.println ("帳號輸入有誤,請重新輸入");
}
}
System.out.println ("是否繼續轉賬?繼續:1 取消:2");
int anjian2;
anjian2=sc.nextInt();
if(anjian2==1)
{
ye-=zhuanzhang;
System.out.println ("正在轉賬-請稍候~~~~");
System.out.println ("轉帳成功");
}
System.out.println ("-----------");
System.out.println ("是否顯示余額?顯示:1不顯示:2");
xianshi=sc.nextInt();
if(xianshi==1)
{
System.out.println ("您的余額為"+ye+"元");
System.out.println ("--------------------------------");
System.out.println ("為了您和您家人的幸福,請節約用錢");
System.out.println ("--------------------------------");
}
System.out.println ("是否列印取款憑條?列印:1 不列印:2");
dayin=sc.nextInt();
Date dd=new Date();
if(dayin==1)
{
System.out.println ("-----------------------中國農業銀行-------------------------");
System.out.println ("\t\t\t----------轉賬憑條-----------\t\t\t");
System.out.println ("帳號:"+zhanghao);
System.out.println ("轉賬帳號:"+zhuanzhanghao);
System.out.println ("轉賬份額:"+zhuanzhang);
System.out.println ("余額:"+ye);
System.out.println ("日期:"+dd.toLocaleString());
System.out.println ("------------------------------------------------------------");
System.out.println ("\t\t\t機器編號:"+bianhao);
System.out.println ("------------------------------------------------------------");
}
int ji;
System.out.println ("是否繼續業務:繼續:1 取卡:2");
ji=sc.nextInt();
if(ji==1)
{
continue;
}
else
{
System.out.println ("請收回您的磁卡,下次再見");
break;
}
}
if(anjian==3)
{
for(;;)
{
System.out.println ("---------------存現功能---------------");
System.out.println ("請輸入您要存款的金額");
jine=sc.nextInt();
if(jine%100==0)
{
break;
}
else
{
System.out.println ("您的輸入有誤,請輸入正百的輸入");
}
}
System.out.println ("請將您的鈔票放入到機器開起的口中(注意:平放!!)");
System.out.println ("正在清點~~~~~z~~~~~z~~~~~z~~~~~z~~~~z~~~~~~z~~~~");
System.out.println ("輸入與放入一至;存現成功");
ye+=jine;
System.out.println ("是否顯示余額?顯示:1不顯示:2");
xianshi=sc.nextInt();
if(xianshi==1)
{
System.out.println ("您的余額為"+ye+"元");
System.out.println ("--------------------------------");
System.out.println ("為了您和您家人的幸福,請節約用錢");
System.out.println ("--------------------------------");
}
System.out.println ("是否列印取款憑條?列印:1 不列印:2");
dayin=sc.nextInt();
Date dd=new Date();
if(dayin==1)
{
System.out.println ("-----------------------中國農業銀行-------------------------");
System.out.println ("\t\t\t----------存現憑條-----------\t\t\t");
System.out.println ("帳號:"+zhanghao);
System.out.println ("存現份額:"+jine);
System.out.println ("余額:"+ye);
System.out.println ("日期:"+dd.toLocaleString());
System.out.println ("------------------------------------------------------------");
System.out.println ("\t\t\t機器編號:"+bianhao);
System.out.println ("------------------------------------------------------------");
}
int ji;
System.out.println ("是否繼續業務:繼續:1 取卡:2");
ji=sc.nextInt();
if(ji==1)
{
continue;
}
else
{
System.out.println ("請收回您的磁卡,下次再見");
break;
}
}
if(anjian==4)
{
int ym,xm,qxm,flag1=0;
for(int j=0;j<3;j++)
{
System.out.println ("------------------改密功能----------------------");
System.out.println ("請輸入原始密碼:");
ym=sc.nextInt();
if(ym==a)
{
System.out.println ("密碼正確");
for(;;)
{
System.out.println ("請輸入新密碼:");
xm=sc.nextInt();
System.out.println ("請再次輸入新密碼");
qxm=sc.nextInt();
if(xm==qxm)
{
a=xm;
System.out.println ("密碼更改成功,請您牢記您的密碼");
break;
}
else
{
System.out.println ("兩次輸入不一致,請重新輸入");
}
}
flag1=1;
break;
}
else
{
System.out.println ("密碼錯誤");
}
}
if(flag1==0)
{
System.out.println ("三次輸入錯誤,密碼更改失敗");
}
int ji;
System.out.println ("是否繼續業務:繼續:1 取卡:2");
ji=sc.nextInt();
if(ji==1)
{
continue;
}
else
{
System.out.println ("請收回您的磁卡,下次再見");
break;
}
}
if(anjian==5)
{
System.out.println ("------------查詢功能-------------");
System.out.println ("您的貴卡余額為:"+ye+"元");
System.out.println ("---------------------------------");
int ji;
System.out.println ("是否繼續業務:繼續:1 取卡:2");
ji=sc.nextInt();
if(ji==1)
{
continue;
}
else
{
System.out.println ("請收回您的磁卡,下次再見");
break;
}
}
if(anjian==0)
{
System.out.println ("請收回您的磁卡,下次再見");
break;
}
}flag=1;
break;
}
}
if(flag==0)
{
System.out.println ("密碼輸入超過三次,ATM機吞卡");
}
}
}
『叄』 農業掌上銀行的軟體源代碼
農業銀行Swift碼 Shanghai Branch ABOCCNBJ010 Beijing Branch ABOCCNBJ090 Tianjin Branch ABOCCNBJ020 Shanxi Branch 山西 ABOCCNBJ040 Neimeng Branch ABOCCNBJ050 Liaoning Branch ABOCCNBJ060 Heilongjiang Branch ABOCCNBJ080 Jiangsu Branch ABOCCNBJ100 Zhejiang Branch ABOCCNBJ110 Anhui Branch ABOCCNBJ120 Fujian Branch ABOCCNBJ130 Jiangxi Branch ABOCCNBJ140 Shandong Branch ABOCCNBJ150 Hubei Branch ABOCCNBJ170 Hunan Branch ABOCCNBJ180 Guangdong Branch ABOCCNBJ190 Guangxi Branch ABOCCNBJ200 Hainan Branch ABOCCNBJ210 Sichuan Branch ABOCCNBJ220 Yunnan Branch ABOCCNBJ240 Shanxi Branch 陝西 ABOCCNBJ260 Gansu Branch ABOCCNBJ270 Xinjiang Branch ABOCCNBJ300 Xinjiang Nongken Branch ABOCCNBJ301 Chongqing Branch ABOCCNBJ310 Dalian Branch ABOCCNBJ340 Qing Branch ABOCCNBJ380 Ningbo Branch ABOCCNBJ390 Shenzhen Branch ABOCCNBJ410 Henan Branch ABOCCNBJ160
『肆』 用java來編寫一個銀行類賬戶和信用卡類的賬戶,信用卡類賬戶繼承銀行賬戶,求源碼
public class Account {
protected String accId;
protected String name;
protected double money;
public Account (String accId,String name){
this(accId,name,0);
}
public Account (String accId,String name,double money){
this.accId = accId;
this.name = name;
this.money = money;
}
public void saveMoney(double money){
if(money <= 0){
System.out.println("存款金額必須大於0");
}
this.money += money;
System.out.println("存款成功");
}
public double getMoney(double money){
if(money <= 0){
System.out.println("取款金額必須大於0");
return 0;
}
if(this.money <= money){
System.out.println("余額不足,無法取款");
return 0;
}
this.money -= money;
System.out.println("取款成功");
return money;
}
public double getBalance(){
return this.money;
}
protected double getOverdraft(){
return 0;
}
// 實現了equals方法,list比較時才能正確
@Override
public boolean equals(Object obj) {
if(obj == null){
return false;
}
if(this == obj){
return true;
}
if(obj instanceof Account){
return this.accId.equals(((Account)obj).accId);
}
return false;
}
@Override
public String toString() {
return "賬戶=" + accId + ",名字=" + name + ",余額=" + money;
}
}
public class Bank {
// Account實現了equals方法,list查找時才能正確
private List<Account> usersAccounts;
public Bank() {
usersAccounts = new ArrayList<Account>();
}
public void addAccount(Account account) {
if (usersAccounts.contains(account)) {
System.out.println("添加失敗,不能添加同樣的賬戶");
return;
}
usersAccounts.add(account);
}
public boolean delAccount(Account account) {
return usersAccounts.remove(account);
}
public boolean delAccount(String accId) {
return delAccount(new Account(accId, null));
}
public boolean existAccount(Account account) {
return usersAccounts.contains(account);
}
public boolean existAccount(String accId) {
return existAccount(new Account(accId, null));
}
public Account getAccount(String accId){
return usersAccounts.get(usersAccounts.indexOf(new Account(accId, null)));
}
public double getAllMoney() {
// 不考慮是否溢出,只是把所有用戶余額相加
double result = 0;
for (Account account : usersAccounts) {
result += account.getBalance();
}
return result;
}
public double getAllOverdraft() {
// 不考慮是否溢出
double result = 0;
for (Account account : usersAccounts) {
result += account.getOverdraft();
}
return result;
}
public int getAccountNum() {
return usersAccounts.size();
}
public int getCreditAccountNum() {
int num = 0;
for (Account account : usersAccounts) {
// instanceof 性能沒有簡單的方法快。
if (account instanceof CreditAccount) {
num++;
}
}
return num;
}
public int getSavingAccountNum() {
int num = 0;
for (Account account : usersAccounts) {
if (account instanceof SavingAccount) {
num++;
}
}
return num;
}
public List<Account> getAllAccount() {
return usersAccounts;
}
}
public class CreditAccount extends Account{
private double overdraft;
public CreditAccount(String accId,String name){
super(accId, name);
this.overdraft = 1000;
}
public CreditAccount(String accId,String name,double money){
this(accId, name,money,1000);
}
public CreditAccount(String accId,String name,double money,double overdraft){
super(accId, name,money);
this.overdraft = overdraft;
}
@Override
public double getMoney(double money) {
if(money <= 0){
System.out.println("取款金額必須大於0");
return 0;
}
if(this.money + overdraft <= money){
System.out.println("余額不足,無法取款");
return 0;
}
this.money -= money;
System.out.println("取款成功");
return money;
}
@Override
public double getOverdraft(){
return overdraft;
}
@Override
public String toString() {
return "賬戶=" + accId + ",名字=" + name + ",余額=" + money + ",透支=" + overdraft;
}
}
public class SavingAccount extends Account {
public SavingAccount(String accId, String name) {
super(accId, name);
}
public SavingAccount(String accId, String name, double money) {
super(accId, name, money);
}
@Override
public double getMoney(double money) {
return super.getMoney(money);
}
@Override
public double getOverdraft() {
return super.getOverdraft();
}
}
public class Test {
private static Bank bank = new Bank();
public static void main(String[] args) {
Test.genAccount();
// 開戶
Account a1 = new CreditAccount("1", "1", 200, 2000);
Account a2 = new SavingAccount("2", "2", 300);
Account a3 = new SavingAccount("3", "3", 400);
Account a4 = new CreditAccount("4", "4", 500, 2000);
Account a5 = new CreditAccount("4", "5", 600, 2000); // 帳號4重
bank.addAccount(a1);
bank.addAccount(a2);
bank.addAccount(a3);
bank.addAccount(a4);
bank.addAccount(a5);
showNowAccount();
// 銷戶
bank.delAccount("1");
bank.delAccount("2");
showNowAccount();
// 存款
if(bank.existAccount("3")){
Account acc = bank.getAccount("3");
acc.saveMoney(100);
}
showNowAccount();
// 取款
if(bank.existAccount("3")){
Account acc = bank.getAccount("3");
System.out.println("余額=" + acc.getBalance());
acc.getMoney(100);
System.out.println("余額=" + acc.getBalance());
acc.getMoney(1000);
System.out.println("余額=" + acc.getBalance());
}
if(bank.existAccount("4")){
Account acc = bank.getAccount("4");
System.out.println("余額=" + acc.getBalance());
acc.getMoney(100);
System.out.println("余額=" + acc.getBalance());
acc.getMoney(1000);
System.out.println("余額=" + acc.getBalance());
acc.getMoney(10000);
System.out.println("余額=" + acc.getBalance());
}
System.out.println(bank.getAccountNum());
System.out.println(bank.getAllMoney());
System.out.println(bank.getAllOverdraft());
System.out.println(bank.getCreditAccountNum());
System.out.println(bank.getSavingAccountNum());
}
public static void genAccount(){
String s = "1000 0000 0000 000";
Account a = null;
for(int i = 1; i < 11; i ++){
if((i & 2) == 0){
a = new CreditAccount(s + String.valueOf(i), "賬戶" + String.valueOf(i));
} else {
a = new SavingAccount(s + String.valueOf(i), "賬戶" + String.valueOf(i));
}
bank.addAccount(a);
}
}
public static void showNowAccount(){
for(Account account : bank.getAllAccount()){
System.out.println(account);
}
}
}