I'm challenging myself to re-do an tech test tech that was completed with makers.
##Requirements
You should be able to interact with the your code via a REPL like IRB or the JavaScript console You don't need to implement a command line interface that takes input from STDIN Must have features for deposits and withdrawal Must have a feature to display account statement (date, amount, balance) Data can be kept in memory (it doesn't need to be stored to a database or anything)
Given a client makes a deposit of 1000 on 10-01-2012 And a deposit of 2000 on 13-01-2012 And a withdrawal of 500 on 14-01-2012 When she prints her bank statement Then she would see:
I previous compelted this task on makers here, but I wanted to attempt the challenge again and go further than the mvp that was provided by adding my own extra functionalities that would make sense in comparision to a bank account/atm.
I started by doing a simple diagram of how I waned to spilt the functionality between two classes and what addtional functionalities I wanted within in the project.
I've also focused on commiting before every failed test and passed test with commits to keep it consistent with addtional commits if there was a bug or a change needed.
In the terminal of the folder input:
- nvm install node
- nvm use node
- npm install jest
- jest - this step is optional if you want to run the test.
You need to be in the directory of the files for this to work
- node
- const BankAccount = require('./BankAccount')
- const Statement = require('./Statement')
- const account = new BankAccount
All bank account start at a nil balance, so withdrawing when having a nil balance will throw an error
- To make a deposit you use account.deposit(500) which would put 500 in the account.
- To make a withdrawal you use account.withdraw(500) which takes 500 out of the account.
- Check the balance of the account by account.getBalance();
- You can alter the amount of the balance without the functions like this: account.balance = 500, which would make it 500 instead of the starting amount of 0
-
const statement = new Statement(account) this puts the bank account in to the statment generator
-
statement.printStatement();
An example of this is below.