Thread View: aus.computers.java
1 messages
1 total messages
Started by Greg
Sat, 20 May 2000 00:00
Vector or loop Problem
Author: Greg
Date: Sat, 20 May 2000 00:00
Date: Sat, 20 May 2000 00:00
83 lines
3038 bytes
3038 bytes
I have a file that holds all the AFL rounds info with the following
format.(the file has 22 rounds)
---------------------------------------
[Round 1]
Richmond, Melbourne
Essendon, Port Adelaide
Kangaroos, West Coast
Adelaide, Western Bulldogs
Fremantle, Geelong
St Kilda, Sydney
Carlton, Brisbane
Hawthorn, Collingwood
[Round 2]
Essendon, Richmond
Melbourne, Kangaroos
Geelong, St Kilda
Port Adelaide, Fremantle
Carlton, Hawthorn
Collingwood, Adelaide
Western Bulldogs, Brisbane
West Coast, Sydney
-----------------------------------------
now the method I'm having troble with is this one
-----------------------------------------
public void readRoundFile(File schedule)
throws IOException
int i = 0;
StringTokenizer gameLine;
String tempStr;
Game games[] = new Game[numOfTeams()/2];
// Game is a class that holds two strings(the name of each team)
int counter = 0;
BufferedReader rndFileIn = new BufferedReader(new
FileReader(schedule));
while((tempStr = rndFileIn.readLine()) != null)
if ((tempStr.charAt(0)) == '[')
{
counter++;
for(i = 0; i<(numOfTeams()/2);i++)
{
gameLine = new StringTokenizer(rndFileIn.readLine(), ",");
games[i] = new Game(gameLine.nextToken(),
gameLine.nextToken());
}
rndFileIn.readLine();
rounds.add(new Round(counter, games)); // rounds is a Vector
// Round is a class that has an int(the round number) and an array
of Games
}
}
System.out.println(((this.getRound(1)).getGame(0)).getTeam(1));
// this should print the first team of the first game of each round
}
------------------------------------------------------------
My problem is that the method seemes to put the last round in the vector 22
times. The output of the System.out.println method prints the Western
Bulldogs 22 times as shown in the last round below
------------------
[Round 22]
Western Bulldogs, Hawthorn
Essendon, Collingwood
Geelong, Sydney
Brisbane, Fremantle
Kangaroos, St Kilda
Adelaide, Port Adelaide
West Coast, Melbourne
Carlton, Richmond
-------------------
I have been stuck at this point for weeks, any help is appreciated.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads