Programming |
Creating a Portfolio
Suppose you have implemented a collection of asset subclasses in a manner similar to the stock class. You can then use a portfolio object to present the individual's financial portfolio. For example, given the following assets
XYZStock = stock('XYZ', 200, 12); SaveAccount = savings('Acc # 1234', 2000, 3.2); Bonds = bond('U.S. Treasury', 1600, 12);
The portfolio display
method summarizes the portfolio contents (because this statement is not terminated by a semicolon).
Descriptor: XYZ Date: 24-Nov-1998 Current Value: 2400.00 Type: stock Number of shares: 200 Share price: 12.00 Descriptor: Acc # 1234 Date: 24-Nov-1998 Current Value: 2000.00 Type: savings Interest Rate: 3.2% Descriptor: U.S. Treasury Date: 24-Nov-1998 Current Value: 1600.00 Type: bond Interest Rate: 12% Assets for Client: Gilbert Bates Total Value: 6000.00
The portfolio pie3
method displays the relative mix of assets using a pie chart.
The Portfolio pie3 Method | Saving and Loading Objects |
© 1994-2005 The MathWorks, Inc.