-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank.java
More file actions
68 lines (57 loc) · 1.26 KB
/
Bank.java
File metadata and controls
68 lines (57 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import java.util.*;
public class Bank {
private String bankId;
private ArrayList <Account> accList = new ArrayList<>();
private ArrayList <ATM> atms = new ArrayList<>();
public Bank(String bank_id){
bankId = bank_id;
}
public String getBankId(){
return bankId;
}
public Account addAccount(String numAcc){
String accId = bankId + numAcc;
Account newAcc = new Account(accId);
accList.add(newAcc);
return newAcc;
}
public ArrayList<Account> getAccList(){
return accList;
}
public ArrayList<ATM> getAtmList(){
return atms;
}
public void addATM(ATM atm){
atms.add(atm);
}
public Account verifyCard(String cardId){
Iterator<Account> iter = accList.iterator();
Account foundAcc = new Account(cardId);
while(iter.hasNext()){
Account cur = iter.next();
if(!cur.getAccId().equals(cardId)){
//System.out.println("Check verify card in bank");
}
else{
foundAcc = cur;
break;
}
foundAcc = null;
}
return foundAcc;
}
public ATM specifyAtm(String atmId){
Iterator<ATM> iter = atms.iterator();
ATM match = new ATM(atmId);
while(iter.hasNext()){
ATM cur = iter.next();
if(cur.getAtmId().equals(atmId)){
match = cur;
break;
}
else
match = null;
}
return match;
}
}//end class