Homework 1
Homework 1
1) Create JUnit tests for methods exposed by the interface Bank in single class called BankTest.
2) Create simple implementation called BankImpl of interface Bank.
3) Run the tests and verify if they succeed. If not, correct/complete the implementation until
there are no failed tests.
During implementation first try to write a couple of tests and then implement methods that are
verified by these tests. For example, write a couple of tests for createAccount and findAccount
methods, then run the tests (initially they should fail), then implement methods in BankImpl and
and run the tests again to verify them. If the tests succeed, write tests other methods, implement
methods, run tests to verify them and so on ... until you have completed the implementation of the
interface.
interface Bank {
/**
* Creates new account and returns its id or returns id of existing account
* @param name holder's name
* @param address holder's address
* @return id of newly created or existing account.
*/
Integer createAccount(String name, String address);
/**
* Finds id of an account.
* @param name holder's name
* @param address holder's address
* @return account id or null if there is no account with given parameters
*/
Integer findAccount(String name, String address);
/**
* Depsits given amount of money to account
* @param id
* @param amount
* @throws AccountIdException, if id is not valid (there is no acccount with given id)
*/
void deposit(Integer id, double amount);
/**
* Returns the balance of the account.
* @param id
* @return balance
* @throws AccountIdException, if id is not valid (there is no acccount with given id)
*/
double getBalance(Integer id);
/**
* Withdraws money from account.
* @param id
* @param amount
* @throws AccountIdException, if id is not valid (there is no acccount with given id)
* @throws InsufficientFundsException, when there is no sufficient funds to perform required
operation.
*/
void withdraw(Integer id, double amount);
/**
* Transfers money between accounts.
* @param idSource
* @param idDestination
* @param amount srodki
* @throws AccountIdException, if id is not valid (there is no acccount with given id)
* @throws InsufficientFundsException, when there is no sufficient funds to perform required
operation
*/
void transfer(Integer idSource, Integer idDestination, double amount);
erajavaee16
Submission status
Attempt number This is attempt 1 ( 3 attempts allowed ).