-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCooperativeBank.java
More file actions
41 lines (35 loc) · 1.5 KB
/
CooperativeBank.java
File metadata and controls
41 lines (35 loc) · 1.5 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
import java.util.*;
public class CooperativeBank extends Bank {
private List<Account> accounts = new ArrayList<>();
private double communityFund;
public CooperativeBank(String bankName, String branchName) {
super(bankName, branchName);
this.communityFund = 1000;
}
@Override
public void openAccount(Account account) {
accounts.add(account);
System.out.println("Account successfully opened at " + bankName + " (Cooperative Bank).");
System.out.println("Welcome to our community banking family!");
}
@Override
public void displayBankInfo() {
System.out.println("\n============ " + bankName + " ============");
System.out.println("Branch: " + branchName);
System.out.println("Bank Code: " + bankCode + " (Cooperative)");
System.out.println("Community Development Fund: ₹" + communityFund);
if (accounts.isEmpty()) {
System.out.println("No accounts have been opened at this branch yet.");
return;
}
System.out.println("\nAccount Details:");
System.out.println("----------------------------------");
for (Account acc : accounts) {
acc.showAccountType();
System.out.println("Account #: " + acc.accountNumber);
System.out.println("Account Holder: " + acc.holderName);
System.out.println("Current Balance: ₹" + acc.getBalance());
System.out.println("----------------------------------");
}
}
}