CS 101 (Spring 1999)
Lab 3: Stock Portfolios

Lab Assigned Design Due
(Mondays 2 PM)
Lab Due
(Fridays 2 PM)
29 Jan 1 Feb 5 Feb


The value of an investor in the stock market can be represented and maintained in a portfolio for that investor. The portfolio contains all information needed to buy and sell stocks that are held by the investor. In our simple world, each portfolio will contain exactly two stocks. Each portfolio also has a reserve of money. Initially, the money is deposited in the portfolio when it is created. Subsequently, the money is affected by the buying and selling of shares for the two stocks that are held.

Before starting:

Some particulars:

The system you design and build will contain at least the following kinds of objects (classes):
A portfolio contains You must provide methods for the buying and selling of a portfolio's current stock. You must also provide a method that sets the current stock to Stock 1 or Stock 2.

Things to consider:

This class represents money in the form of dollars and eighths of dollars. For example
  MarketValue v1 = new MarketValue(3,4);
creates a value that is 3 dollars and 4/8 dollars, or $3.50. The toString method for MarketValue must print out the value in stock form: 3 4/8.

Although MarketValue may appear to be similar to Quote, you should view Quote as an interface for obtaining stock quotes, while MarketValue is much more general. In particular, think about methods you need to do the following.

What to turn in:

  1. The cover sheet, properly completed
  2. For each class in your design, including the Portfolio and MarketValue classes, provide the following.
  3. Be sure to do the same for any extra classes in your design.
Choose names and type signatures (that is, the API) for the methods in the classes of your design, paying attention to

Quote API

As an example of an API, and to assist you in developing your solution in Lab, the API for the Quote class is as follows.
Public Accessors
Other Public Methods
Public Fields
Private Methods
Private Fields
Exceptional behavior

Last modified 08:22:03 CST 27 January 1999 by Ron K. Cytron