| Programming and Data Types |
資産setメソッド
資産クラスsetメソッドは、サブクラスsetメソッドによって呼ばれます。このメソッドは、資産オブジェクトとプロパティ名/値の可変長引数の一覧を受け入れて、変更されたオブジェクトを戻します。
function a = set(a,varargin)
% SET 資産プロパティを設定し、更新されたオブジェクトを戻します。
property_argin = varargin;
while length(property_argin) >= 2,
prop = property_argin{1};
val = property_argin{2};
property_argin = property_argin(3:end);
switch prop
case 'Descriptor'
a.descriptor = val;
case 'Date'
a.date = val;
case 'CurrentValue'
a.current_value = val;
otherwise
error('Asset properties: Descriptor, Date, CurrentValue')
end
end
サブクラスsetメソッドは、資産setメソッドを呼び出しますが、MATLABでは、参照によって引数を渡すことができないため、変更されたオブジェクトを戻す機能を必要とします。例題は、株式setメソッドを参照して?ださい。
| 資産getメソッド | 資産subsrefメソッド |