-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank.java
More file actions
46 lines (30 loc) · 979 Bytes
/
Copy pathBank.java
File metadata and controls
46 lines (30 loc) · 979 Bytes
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
import java.util.*;
public class Bank{
private PriorityQueue<Customer> customers = new PriorityQueue<Customer>(new CustomerPriorityComparator());
private ArrayList<BankAccount> accounts = new ArrayList<BankAccount>();
public void addCustomer(Customer aCustomer){
customers.add(aCustomer);
}
public Customer[] getCustomers(){
int customersSize = customers.size();
Customer[] copyCustomers = new Customer[customersSize];
int i = 0;
for (Customer aCustomer : customers){
copyCustomers[i] = aCustomer;
i++;
}
return copyCustomers;
}
public void addAccount(BankAccount anAccount){
accounts.add(anAccount);
}
public BankAccount[] getAccounts(){
BankAccount[] returnAccounts = new BankAccount[accounts.size()];
int counter = 0;
for (BankAccount anAccount : accounts){
returnAccounts[counter] = anAccount;
counter++;
}
return returnAccounts;
}
}