Class Bank
java.lang.Object
bank.Bank
- All Implemented Interfaces:
Serializable
Banks have clients and accounts. New clients can open new accounts or join
existing accounts.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaccount(int number) accounts()Return all the accounts as an unmodifiable collection.client(int number) clients()Return all the account holders as an unmodifiable collection.createAccount(double amount) Create and register account.final booleanfinal StringgetName()voidimportFile(String filename) Simple function to parse basic information about accounts and holders.static BankvoidregisterClient(int number, String name) final voidremoveAccount(Account account) Remove an account.voidremoveClient(int number) void
-
Constructor Details
-
Bank
-
-
Method Details
-
getName
- Returns:
- the name of the bank.
-
equals
-
createAccount
Create and register account.- Parameters:
amount- initial balance for the account.- Returns:
- the new account.
-
removeAccount
Remove an account. An account can only be removed if its total balance is zero. If it is not possible to remove an account, an exception is thrown.- Parameters:
account- the account to be removed.- Throws:
InvalidRemovalException
-
account
- Parameters:
number- the account number.- Returns:
- the account
- Throws:
NoSuchAccountException
-
accounts
Return all the accounts as an unmodifiable collection.- Returns:
- a collection with all the accounts.
-
registerClient
- Parameters:
number- the client numbername- the client name- Throws:
DuplicateClientException
-
removeClient
- Parameters:
number- the client number- Throws:
NoSuchClientException
-
clients
Return all the account holders as an unmodifiable collection.- Returns:
- a collection with all the account holders.
-
client
- Parameters:
number- the client number- Returns:
- the account holder
- Throws:
NoSuchClientException
-
importFile
Simple function to parse basic information about accounts and holders. ACCOUNT:account_number HOLDER:holder_number:holder_name- Parameters:
filename- input file
-
save
- Parameters:
filename-bank-- Throws:
IOException
-
load
- Parameters:
filename-- Returns:
- a new bank recovered from file.
- Throws:
IOExceptionClassNotFoundException
-