I have to create a bank application in OOP way that supports: Withdraw, Deposit, Maintain Transaction List.
I have come up with following class:
1. Transaction: *Properties*: TransactionType(Debit/Credit) Amount DateTime 2. Account *Properties*: Id List<Transaction> *Methods*: withdraw deposit 3. Customer *Properties*: Id Name List<Account> 4. Bank *Properties*: List<Customer>
Now to add customer and add account I have created
And to withdraw and deposit I have created
DepositService(I could create TransactionService to include both)
Lets say user want to deposit $100
DepositService ( e.g. controller in case of mvc) would call
deposit method of this
DepositService and would pass in
But I don’t have ready collection of
Account objects to get
Account object for this
AccountId instead I have collections of
Bank class. So I could not directly get
Account object and deposit amount to it.
So I have come up with following ways:
- Pass in
Customerobject and then get
Accountobject from that
- Keep List of
Bankclass instead of list of
Accountdirectly from this list and deposit amount. But in this case where to maintain customer list? Because
Accountwould have customerId in that case and not
Customerobject. Now I need to keep map of
Customerobject but where to keep this map?
What could be better way to solve this problem?