- In a bank you have business accounts and private accounts.
- You can transfer money between accounts using transactions.
- For private accounts the transaction fee is 0.01 € for business accounts the transaction fee is 0.02 €.
- write an
Account
class- The class should hold a reference to the
ledger
- It should also have a
name
to identify the account
- The class should hold a reference to the
- implement a
Transaction
class- A transaction consists of an optional
sender
(Type: Account) -
receiver
(Type: Account) -
amount
(Type: Number) -
reference
(Type: String)
- A transaction consists of an optional
- implement a
Ledger
class that keeps all transactions- It should keep an array of
transactions
- Have a member variable
bankAccount
the keeps a reference for the bank account - Implement a function
addTransaction(transaction)
- Implement a function
calculateAmountForAccount(account)
usingreduce
- Implement a function
findTransactionsForAccount(account)
usingfilter
- It should keep an array of
- Add convenience functions to
Account
- add a
send
function that generates two transactions- The actual transaction
- A transaction for the fee for the bank
- add a getter to calculate the
amount
- add a getter to retrieve all
transactions
that are related to the account
- add a
- specialize
Account
class into aBusinessAccount
- override the
send
function to respect different transaction fees for businesses
- override the
You can see the tests in integration-test
. Try to run write the classes so they are satisfying the tests. You can also follow the commits in the solution
branch to see the solution.
npm install # install all dependencies
npm test # runs all tests
npm start # starts a dev server on localhost:8000