MATLAB Object-Oriented Programming

(Joyce) #1

  • assignStatus — Method that assigns a status to a BankAccount object. Serves as
    the listener callback.

  • addAccount — Method that creates the InsufficientFunds listener.


Implementing the AccountManager Class


The AccountManager class implements both methods as static because there is no need
for an AccountManager object. These methods operate on BankAccount objects.


The AccountManager is not intended to be instantiated. Separating the functionality of
the AccountManager class from the BankAccount class provides greater flexibility and
extensibility. For example, doing so enables you to:



  • Extend the AccountManager class to support other types of accounts while keeping
    the individual account classes simple and specialized.

  • Change the criteria for the account status without affecting the compatibility of saved
    and loaded BankAccount objects.

  • Develop an Account superclass that factors out what is common to all accounts
    without requiring each subclass to implement the account management functionality


AccountManager Class Synopsis


AccountManager Class Discussion
classdef AccountManager This class defines the
InsufficentFunds event listener and
the listener callback.
methods (Static) There is no need to create an instance of
this class so the methods defined are
static. See “Static Methods” on page 9-
32.

Developing Classes — Typical Workflow
Free download pdf