Instructor: J. Liu
Assignment 3. Due Tuesday April 1 in class.
updatePrice(). You are also provided with a class TseStock.java that extends the
Stockclass for stocks in the Toronto Stock Exchange. The abstract method
Stockclass is implemented in the
TseStockclass by extracting the price information from the Toronto Stock Exchange site.
You are to write a class, called
that extends the
Stock class for stocks in the United States.
In order to update its stock price, we can use the URL for the New York
Stock Exchange. For example, to access the quote for "IBM", we use
http://www.nyse.com/cgi-bin/ny_quote?sym=IBMSimilarly, to access the quote for "MSFT", we use
http://www.nyse.com/cgi-bin/ny_quote?sym=MSFTUse this information to implement the
UsStockby extracting the latest price from this site. (Study the returned HTML document from the NYSE site to see where the last traded stock price is located. Also find out messages from the returned HTML document in case an invalid symbol is used.)
UsStock should also override the
Stock. For example, the string representations
of the IBM and MSFT stocks should be "[U/IBM]" and "[U/MSFT]"
respectively (instead of "[IBM]" and "[MSFT]").
TseStock class serves as an example of how you might
A simple tester
is also provided to test your
UsStock class and to illustrate
the notion of polymorphism.
UsStockclasses of Part 1. It is on the development of a a Java
JFramethat allows the user to enter up to 10 stock symbols and the
JFramewill get and display the latest stock quotes. The stock symbols can either be for TSE or for US stocks. For US stocks, the symbol entered should be preceded with "U/". For example, "BCE", "NT", "RY", "BMO" can be entered for TSE stocks; and "U/IBM", "U/MSFT", "U/AOL", "U/SUNW" should be entered for the corresponding US stocks.
You are already provided with a Java program
(Run it to get familiar with its behavior).
You are to write a Java code, called
StockJFrame and overrides the
actionPerformed(ActionEvent e) method.
You may add additional static/instance variables and methods to
MyStockJFrame class the way you see appropriate.
Note that in the
init() method of
ten text fields for stock symbols, ten display fields for stock prices
and a "Refresh" button have been set up.
Users can enter the selected stock symbols into
the ten text fields.
Either TSE or US stock symbols can be entered into any one of the text fields.
whenever a symbol is entered (with a carriage return), its latest stock price
should be displayed.
If the stock symbol entered is invalid, the string "?????" should appear
in the area for its stock price.
Any time when the "Refresh" button is pushed, all the stock prices
MyStockJFrame should be updated by the latest quotes
from the stock exchange sites.
Last Updated: 02/25/2003