You are on page 1of 2

+loadList(fileName:String):int

+loadList(fileName:String):int Opens the file fileName and reads all the


StockTrades into the list. fileName is the complete path and file name.
loadList should contain no hard-coded values. You will need to set a
delimiter for the scanner as discussed in the FAQ file. Use this:
s.useDelimiter(", |\n|\r\n|\f")

public int loadList(String fileName)throw FileNotFoundException{


Scanner s =new Scanner(new File("c:\\myinput.txt"));
boolean morelines = true;
//Symbol, Date , High, Low, Close, Volume
//HSE-T, Mar-23-2000, 5.112, 4.826, 4.85, 1286205
while(morelines){
System.out.println(s.nextline);
System.out.println(" ,"s.nextdouble);
System.out.println(" ," s.nextlong);
s.useDelimiter(", |\n|\r\n|\f")
}
moreline = fase;
trades[antualSize].insert(.... )

return actualSize
}

Here is more information about TestList.


TestList should consist of only a main method with no instance variables or meth
ods. In
TestList.main, you should do the following:
1. Instantiate a TradeArrayList object called eyeTrade
2. Invoke eyeTrade.loadList to load the file of StockTrades. You should
catch the FileNotFoundException and print the message returned by it
instead of advertising that your main may throw this exception.
3. Using a for loop, print the elements 2630 to 2640 of your array, one per line
, in the
format returned by StockTrade.toString.
4. Print the following StockTrades in the same format (and in the order below!).
a. HSE-T, Mar-15-2000
b. HSE-T, Mar-22-2000
c. BCE-T, Dec-15-2006
Make sure to read the FAQ file posted on the website regularly

public void static main () {


try {
TradeArrayList eyeTrade = new TradeArrayList;
eyeTrade.loadList(Filename);
for (int i = 2630 ; i >= 2640 ; i++){
eyeTrade.trade[i].toString();

}
}
catch (Exception e) {
System.out.println("Caught Exception " +
e.FileNotFoundException );

You might also like