any one good with Java?? need help on home work

  • We are currently upgrading MFK. thanks! -neo

Arrowanaoscars

Feeder Fish
MFK Member
Feb 28, 2011
114
0
0
Colorado
ok so im new to java and i have a homework assignment to read from a text file and put them in to a 2d array the text file looks like this..

5
0
-1,0
1,-1,0
-1,1,-1,0
-1,-1,-1,1,0

the 5 is to be 5 rows and 5 columns then make the chart from there and it only fills half of the chart i can attach the actual home work if any one has any experience it would be much appreciated or any links to any tutorials
 
and yes i know probly worst forum for a java code question but no where else ive tried has helped and its due Thursday >.>

going to go get the actual assignment just in case on of you guys has any clue how to do it i reread my first post and tells almost no deatail so ill repost with the actual assignment detail
 
do it part by part.



-START-
initialize an array.

file opener. Load up 1kb of the file, then send it down the line, and loops this.
{
$count11++

Parser, everytime there is a EOL write to a temp value.

$temp = data_from_parser.

if( temp value = true) {
Paraser2, CSV parser
$temp2
count2++

$array[$temp][$temp2]
}

while( count2 > 5){
insert NULL to array
$array[$temp][NULL]
}



//end file load loop
}
 
Dont load all the file at once (unless your teacher never sees your code.

Parse first by EOL
Paras eace line by CSV

when there is less then 5 values from the CSV paras insert null values untill there is a total of 5 (you should really query the array to find out exactly how much data is there, you should rely on your own code to be perfect, but this should be alright for this simply application)
 
ya trying to do all the coding my self but seeing an example helps me alot the biggest map you have to make is 1000 i put the assignment up to give a better description
 
public Map(String infilename) {
int size;
try{


input = new Scanner(new File(infilename));

size = input.nextInt();
Size = size;
String stuff;


for(int i = 0; i < Size; i++){
String line = input.nextLine();
for(int j = 0; j < counter; j++){
StringTokenizer st = new StringTokenizer(line,",");
String city = st.nextToken();
int cityInt = Integer.parseInt(city);
map[j] = cityInt;
}
counter++;
}

this is my tokenizer but it doesent seem to work it reads the correct size but not the right data if you would like i could send you the whole code for your in put
 
MonsterFishKeepers.com