Deviopath › TypeScript

Bank Account with a Private Balance

Medium · Classes

Finish the BankAccount class. balance is private, so code outside the class can only change it through the methods.

- deposit(amount): add amount and return the new balance

- withdraw(amount): if amount is more than the balance return false and change nothing, otherwise subtract it and return true

- getBalance(): return the balance

runBank is already written: it replays a list of operations on a new account and returns every result.

Next: Payroll with Interface extends