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.

9 Classes and Objects<br />

Inheritance Model for the Asset Class<br />

An example of a simple inheritance relationship using an asset base class is<br />

showninthisdiagram.<br />

Asshowninthediagram,thestock, bond, andsavings classes inherit<br />

structure fields from the asset class. In this example, the asset class is<br />

used to provide storage for data common to all subclasses and to share asset<br />

methods with these subclasses. This example shows how to implement the<br />

asset and stock classes. The bond and savings classes can be implemented in<br />

awaythatisverysimilartothestock class, as would other types of asset<br />

subclasses.<br />

Asset Class Design<br />

Theassetclassprovidesstorageandaccess for information common to all<br />

asset children. It is not intended to be instantiated directly, so it does not<br />

require an extensive set of methods. To serve its purpose, the class needs to<br />

contain the following methods:<br />

9-42

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

Saved successfully!

Ooh no, something went wrong!