Programming |
The Asset get Method
The asset class needs methods to access the data contained in asset objects. The following function implements a get
method for the class. It uses capitalized property names rather than literal field names to provide an interface similar to other MATLAB objects.
function val = get(a, propName) % GET Get asset properties from the specified object % and return the value switch propName case 'Descriptor' val = a.descriptor; case 'Date' val = a.date; case 'CurrentValue' val = a.currentValue; otherwise error([propName,' Is not a valid asset property']) end
This function accepts an object and a property name and uses a switch
statement to determine which field to access. This method is called by the subclass get
methods when accessing the data in the inherited properties. See The Stock get Method for an example.
The Asset Constructor Method | The Asset set Method |
© 1994-2005 The MathWorks, Inc.