Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose you design a banking application. The class CheckingAccount already exis

ID: 3924114 • Letter: S

Question

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

Explanation / Answer

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.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote