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

Respuesta :

Answer:

Strategy

Explanation:

The strategic design pattern is defined as the behavioral design pattern that enables the selecting of a algorithm for the runtime. Here the code receives a run-time instructions regarding the family of the algorithms to be used.

In the context, the strategic pattern is used for the application for implementing OverdraftCheckingAccount class. And the main aspect of this strategic pattern  is the reusability of the code. It is behavioral pattern.