-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank.java
More file actions
33 lines (28 loc) · 958 Bytes
/
Bank.java
File metadata and controls
33 lines (28 loc) · 958 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
import java.util.*;
public class Bank {
private List<Account> accounts = new ArrayList<>();
private List<Transaction> transactions = new ArrayList<>();
public Account createAccount(String accountNumber, String name) {
Account acc = new Account(accountNumber, name);
accounts.add(acc);
return acc;
}
public Account getAccount(String accountNumber) {
for (Account acc : accounts) {
if (acc.getAccountNumber().equals(accountNumber)) {
return acc;
}
}
return null;
}
public void recordTransaction(String accNo, String type, double amount) {
transactions.add(new Transaction(accNo, type, amount));
}
public void showMiniStatement(String accountNumber) {
for (Transaction t : transactions) {
if (t.toString().contains(accountNumber)) {
System.out.println(t);
}
}
}
}