-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank.java
More file actions
84 lines (66 loc) · 2.73 KB
/
Bank.java
File metadata and controls
84 lines (66 loc) · 2.73 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import java.util.LinkedList;
public class Bank {
private LinkedList<Customer> customers = new LinkedList<Customer>();
private int numberOfCustomers;
private String bankName;
public Bank(String bName){
bankName = bName;
}
public void addCustomer(Customer c){
customers.add(c);
}
public void deleteCustomer(int index){
customers.remove(index);
}
public int getNumberOfCustomers() {
return customers.size();
}
public Customer getCustomers(int index) {
return customers.get(index);
}
public int searchCustomer(long snNumber, String expirationDate,int cvvNumber, int pinNumber){
int index = -1; //declare the index to be negative one at start
for(int i=0;i<customers.size();i++){ //Traverse through the linked list,
Customer llElement = customers.get(i);
long llcardNumber = llElement.getAccount().getSn();
String llcardED = llElement.getAccount().getEd();
int llcardCVV = llElement.getAccount().getCvv();
int llcardPIN = llElement.getAccount().getPin();
// Check whether the current element's data values matches with the one from parameter
if(llcardNumber==snNumber && llcardED.equals(expirationDate )&& llcardCVV==cvvNumber && llcardPIN==pinNumber){
index = i; //change the index's value to current index
return index;
}
}
return index;
}
public int searchTarget(long accountNumber){
int index = -1; //declare the index to be negative one at start
for(int i=0;i<customers.size();i++){ //Traverse through the linked list,
Customer llElement = customers.get(i);
long llAccountNumber = llElement.getAccountNumber();
// Check whether current element's account number is the same with parameter input's
if(llAccountNumber==accountNumber){
index = i; //change the index's value to current index
return index;
}
}
return index;
}
public boolean searchIDAvailability(String idNumber){
for(int i=0;i<customers.size();i++){
Customer llElement = customers.get(i);
String llIDNumber = llElement.getIdNumber();
if(llIDNumber.equals(idNumber)){return false;}
}
return true;
}
public boolean searchCNAvailability(long cardNumber){
for(int i=0;i<customers.size();i++){
Customer llElement = customers.get(i);
long llCardNumber = llElement.getAccount().getSn();
if(llCardNumber==cardNumber){return false;}
}
return true;
}
}