Developing Classes — Typical Workflow
In this section...
“Formulating a Class” on page 3-8
“Specifying Class Components” on page 3-9
“BankAccount Class Implementation” on page 3-10
“Formulating the AccountManager Class” on page 3-14
“Implementing the AccountManager Class” on page 3-15
“AccountManager Class Synopsis” on page 3-15
“Using BankAccount Objects” on page 3-17
Formulating a Class
This example discusses how to approach the design and implementation of a class. The
objective of this class is to represent a familiar concept (a bank account). However, you
can apply the same approach to most class designs.
To design a class that represents a bank account, first determine the elements of data and
the operations that form your abstraction of a bank account. For example, a bank account
has:
- An account number
- An account balance
- A status (open, closed, etc.)
You must perform certain operations on a bank account:
- Create an object for each bank account
- Deposit money
- Withdraw money
- Generate a statement
- Save and load the BankAccount object
If the balance is too low and you attempt to withdraw money, the bank account broadcasts
a notice. When this event occurs, the bank account broadcasts a notice to other entities
3 MATLAB Classes Overview