Package bank
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:
- Serialized Form
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaccount(int id)accounts()Return all the accounts as an unmodifiable collection.client(int id)clients()Return all the account holders as an unmodifiable collection.createAccount(double amount)Create and register account.booleangetName()voidimportFile(String filename)Simple function to parse basic information about accounts and holders.static BankvoidregisterClient(int id, String name)voidremoveAccount(Account account)Remove an account.voidremoveClient(int id)void
-
Constructor Details
-
Bank
Constructor.- Parameters:
name- bank name.
-
-
Method Details
-
getName
- Returns:
- the name of the bank.
-
equals
- Overrides:
equalsin classObject- See Also:
Object.equals(java.lang.Object)
-
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:
id- 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:
name-id-- Throws:
DuplicateClientException
-
removeClient
- Parameters:
id- the account holder's id.- Throws:
NoSuchClientException
-
clients
Return all the account holders as an unmodifiable collection.- Returns:
- a collection with all the account holders.
-
client
- Parameters:
id- the account holder's id- Returns:
- the account holder
- Throws:
NoSuchClientException
-
importFile
Simple function to parse basic information about accounts and holders. ACCOUNT:account_id HOLDER:holder_id:holder_name- Parameters:
filename- input file
-
save
- Parameters:
bank-filename-- Throws:
IOException
-
load
- Parameters:
filename-- Returns:
- a new bank recovered from file.
- Throws:
IOExceptionClassNotFoundException
-