MATLAB Object-Oriented Programming

(Joyce) #1

Bonds Class


The Bonds class represents a specific type of financial asset. It is a concrete class that
implements the abstract members defined by the Assets class and defines class
properties and methods specific to this type of asset.


Properties


The Bonds class defines these properties:



  • FaceValue — Face value of the bond.

  • Yield — Annual interest rate of the bond.

  • Type — Bonds class implementation of the abstract property defined by the Assets
    class. This concrete property must use the same attributes as the abstract version
    (that is, SetAccess private).

  • CurrentYield — Dependent property for the current yield, The get.CurrentYield
    property get method obtains the value from web services.


Methods


The Bonds class defines these methods:



  • Bonds — The constructor assigns property values and supports a default constructor
    called with no input arguments.

  • getCurrentVlaue — This method is the Bonds class implementation of the abstract
    method defined by the Assets class. It returns the current value of this asset.

  • get.CurrentYield — The property get method for the dependent CurrentYield
    property returns the current yield on this bond. For information on how to access web
    serviced from MATLAB, see the webread function.


Bonds Class Code


classdef Bonds < financial.Assets
properties
FaceValue double = 0
Yield double = 0
end
properties (SetAccess = private)
Type = "Bonds"
end
properties (Dependent)


A Class Hierarchy for Heterogeneous Arrays
Free download pdf