-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank.java
More file actions
73 lines (63 loc) · 1.49 KB
/
Bank.java
File metadata and controls
73 lines (63 loc) · 1.49 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
package ATM_Network_System;
/**
* The Bank class
*
* @author Arvind Bhamidipati
* @version 1.0
*/
import java.util.ArrayList;
public class Bank {
private String bank_id;
private ArrayList<Account> accounts;
private ATM atm;
/**
* Bank Instance.
* @param bank_id
*/
public Bank(String bank_id) {
this.atm = new ATM(bank_id, this, 100);
this.bank_id = bank_id;
this.accounts = new ArrayList<Account>();
}
/**
* Adds a new account to the Bank
* @param newAccount
*/
public void addAccount(Account newAccount) {
accounts.add(newAccount);
}
/**
* Check to make sure the passowrd is correct to access Account.
* @param cardNumber
* @param accountPassword
* @return account
*/
public Account verifyPassword(String cardNumber, String accountPassword) {
for (Account account : accounts) {
if (account.getCashCard().getCardNumber().equals(cardNumber)) {
if (account.getAccountPassword().equals(accountPassword)) {
return account;
}
}
}
return null;
}
/**
* Bank tells us what accounts are in each bank and how much you have in each account.
*/
public void printBankState() {
// print out all the accounts
System.out.println("Bank " + bank_id + " status: ");
for (Account account : accounts) {
System.out.println("Account number: " + account.getAccountNumber() + " Account balance: "
+ account.returnCurrentBalance());
}
System.out.println();
}
ATM getATM(){
return atm;
}
String getBank_ID() {
return bank_id;
}
}