23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example — Assets and Asset Subclasses<br />

Example — Assets and Asset Subclasses<br />

This example is divided into the following topics:<br />

• “Inheritance Model for the Asset Class” on page 9-42<br />

• “Asset Class Design” on page 9-42<br />

• “Other Asset Methods” on page 9-43<br />

• “The Asset Constructor Method” on page 9-43<br />

• “The Asset get Method” on page 9-44<br />

• “The Asset set Method” on page 9-45<br />

• “The Asset subsref Method” on page 9-46<br />

• “The Asset subsasgn Method” on page 9-47<br />

• “The Asset display Method” on page 9-48<br />

• “The Asset fieldcount Method” on page 9-49<br />

• “Designing the Stock Class” on page 9-49<br />

• “The Stock Constructor Method” on page 9-50<br />

• “The Stock get Method” on page 9-52<br />

• “The Stock set Method” on page 9-53<br />

• “The Stock subsref Method” on page 9-54<br />

• “The Stock subsasgn Method” on page 9-55<br />

• “The Stock display Method” on page 9-57<br />

As an example of simple inheritance, consider a general asset class that can<br />

be used to represent any item that has monetary value. Some examples<br />

of an asset are: stocks, bonds, savings accounts, and any other piece of<br />

property. In designing this collection of classes, the asset class holds the<br />

data that is common to all of the specialized asset subclasses. The individual<br />

asset subclasses, such as the stock class, inherit the asset properties and<br />

contribute additional properties. The subclasses are “kinds of” assets.<br />

9-41

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!