I am creating a bank software system.
In this system, there are 3 account types: Savings, Checking, CD.
Each account from any type has an ID, apr, and amount, and we can withdraw from it.
So I can have an abstract class Account
, that contains ID, apr, amount variables, and withdraw(int amount)
method.
But, we can deposit only in Savings and Checking accounts, and we can transfer money only between Savings and Checking accounts.
So the 2 methods deposit(int amount) and transfer(id, amount) can not be defined in the Account
abstract class.
I am thinking about making an interface nonCDAccount
, that contains 2 methods: deposit()
and transfer()
, and implementing that interface from Savings
and Checking
classes.
Is it a good idea? If not, what should I do?