Planning consisted of:
- User stories written
- Classes and functions illustrated on wireframe.cc
- Test templates were written with edge cases considered
- Two classes: BankAccount, and a model class Transaction
- As this is a simple program I believed it to be counter-intuitive to complicate matters with more than two classes.
- The Transaction class handles a single transaction (date, deposit, withdrawal, balance)
- The BankAccount class tracks the overall balance, manages instances of Transaction and ultimately logs the statement to the console.
- I had considered creating a Date class due to JS not having a concise way to display DD/MM/YYY however in the end I settled with a simple function that handled that formatting, which I did think complicated the BankAccount class too much. If the app was to be expanded then I would consider a date/timestamp class with appropriate functions.
Navigate to root of project folder
npm install
node repl.js
Commands:
- Deposit money into the account (where 'amount' is an integer)
bankAccount.deposit(amount, manualDate)
- Withdraw money from the account (where 'amount' is an integer)
bankAccount.withdraw(amount, manualDate)
- Print Bank Statement
bankAccount.printStatement()
- Print Balance (as an integer only)
bankAccount.printBalance()
NB It is possible to input a date to a deposit or withdrawal manually. If a date is not passed to the above deposit and withdrawal commands, it will automatically input the date in which you run the command.
- If you wish to check the testing of the code, run the below from project root
jest
- Testing => jest ~ 29.4.3
- Lint:
eslint => 8.34.0,
eslint-config-airbnb-base => 15.0.0,
eslint-config-prettier => 8.6.0,
eslint-plugin-import => 2.27.5,
prettier => 2.8.4
Please see:
./images