You need to store information for bank accounts.
Assume that you only need to store the current balance, and the total number of transactions for each account. The goal for the problem is to avoid duplicating code between the three types of accounts and to make sure future types of accounts will properly respond to events of deposit and withdraw. Try to expose as little data of the super class as possible to the subclasses.
There can be multiple correct solutions. Use the solution you think is the best.
An account needs to respond to the following messages:
constructor(initialBalance)
deposit(amount) : put money to the account
withdraw(amount): get money from the account
endMonth(): to run at the end of each month to conclude the month: Apply the end-of-month charge; print out a summary; zero the transaction count.
Types of Accounts
Fee
Fixed $5.00 fee at the end of the month
Nickle ‘n Dime
$0.50 fee for each withdrawal charged at the end of the month
Gambler
For each withdrawal With probability 0.49 there is no fee and no deduction to the balance
With probability 0.51 twice the amount is deducted from the balance