Suppose you design a banking application The class CheckingA

Suppose you design a banking application. The class CheckingAccount already exists and implements interface Account. Another class that implements the Account interface is CreditAccount. When the user calls creditAccount.withdraw(amount) it actually makes a loan from the bank. Now you have to write the class OverdraftCheckingAccount, that also implements Account and that provides overdraft protection, meaning that if overdraftCheckingAccount.withdraw(amount) brings the balance below 0, it will actually withdraw the difference from a CreditAccount linked to the OverdraftCheckingAccount object.
What design pattern is appropriate in this case for implementing the OverdraftCheckingAccount class ?

a) Observer

b) Decorator

c) Strategy

d) Composite

Solution

The design pattern appropriate for implementing the OverdraftCheckingAccount class is a) Observer

In behavioral design pattern, Observer design is a means of reporting changes to a number of classes.

Suppose you design a banking application. The class CheckingAccount already exists and implements interface Account. Another class that implements the Account i

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site