-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank.java
More file actions
33 lines (27 loc) · 1 KB
/
Bank.java
File metadata and controls
33 lines (27 loc) · 1 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
import java.util.ArrayList;
import java.util.List;
class Bank {
private List<Account> accounts = new ArrayList<>();
public void createSavingsAccount(int accountId, String name, double balance, double interestRate) {
Account account = new SavingsAccount(accountId, name, balance, interestRate);
accounts.add(account);
System.out.println("Savings Account created successfully.");
}
public void displayAllAccounts() {
for (Account account : accounts) {
System.out.println("\nAccount ID: " + account.accountId);
System.out.println("Holder Name: " + account.accountHolderName);
account.displayBalance();
account.displayAccountType();
}
}
public Account findAccount(int accountId) {
for (Account account : accounts) {
if (account.accountId == accountId) {
return account;
}
}
System.out.println("Account not found.");
return null;
}
}