MATLAB Object-Oriented Programming
methods function r = mtimes(obj1,obj2) obj1 = DocPolynom(obj1); obj2 = DocPolynom(obj2); r = DocPolynom(conv(obj1.coef,obj2.coef ...
...
Designing Related Classes 20 ...
A Class Hierarchy for Heterogeneous Arrays In this section... “Interfaces Based on Heterogeneous Arrays” on page 20-2 “Define He ...
Textual description Type (stock, bond, or cash) Means to determine the current value of the asset Heterogeneous arrays of thes ...
20 Designing Related Classes ...
Assets Class The Assets class: Derives directly from matlab.mixin.Heterogeneous Is the root of the heterogeneous hierarchy Is a ...
Concrete methods defined by superclasses in a heterogeneous hierarchy must specify the Sealed attribute. Sealing these methods p ...
function defaultObject = getDefaultScalarElement defaultObject = financial.DefaultAsset; end end methods (Sealed) % Implemented ...
getCurrentValue — This method is the Stocks class implementation of the abstract method defined by the Assets class. It returns ...
Bonds Class The Bonds class represents a specific type of financial asset. It is a concrete class that implements the abstract m ...
CurrentYield double = 0 end methods function b = Bonds(description,facevalue,yield) if nargin == 0 description = ''; facevalue = ...
Type — Cash class implementation of the abstract property defined by the Assets class. This concrete property must use the same ...
newValue = c.Amount - amount; if newValue < 0 c.Amount = 0; disp('Your balance is $0.00') else c.Amount = newValue; end end e ...
A Class Hierarchy for Heterogeneous Arrays ...
DefaultAsset Class Code classdef DefaultAsset < financial.Assets % file: +financial.@DefaultAsset/DefaultAsset.m properties ( ...
types(k) = obj(k).Type; values(k) = obj(k).getCurrentValue; end t = table; t.Description = descs'; t.Type = types'; t.Value = va ...
title(stg,'FontSize',10) end Create an Assets Array These statements create a heterogeneous array by concatenating the Stocks, B ...
See Also Related Examples “Designing Heterogeneous Class Hierarchies” on page 10-24 “Validate Property Values” on page 8-24 “Se ...
...
«
34
35
36
37
38
39
40
41
42
43
»
Free download pdf