i have to have my socket read an 80x80 text file into an 80x80 2d array. it has to be character by character and the resulting array has to be a carbon copy of the text file layout because it will be used to move a mouse through a maze. i tried to use readNext but i realized that its return type is int and nextLine would log an entire line into one index. im stuck and every other post i found is reading words or ints into an array . if you have time the protocol for the sockets will be:
ooo
wmw
wpw
so basically o=outside of maze, m=mouse, w=wall, and p=path the server needs to send a 3x3 snapshot of where the mouse is within the 80x80 maze after each move that the mouse makes. im having trouble wrapping my head around getting that worked out. so anyway heres the code for the server socket that ive gotten to so far. just imagine a 80x80 character textfile that graphically represents the route of the maze since i cant really copy and paste it. all i need in the code is what to use to fill in the array and thoughts on sending the protocol back and forth. i can get the sockets communicating later
public class serverSocket {
private static ServerSocket server = null;
public static void main (System [] args){
File file = new File("\\MAC\\Users\\Tucker\\mazehardcode.rtf");
FileReader fr = new FileReader(file);
char mazeFile [][]=new char[80][80];
for(int i = 0;i <80;i++){
for(int j = 0; j<80; j++){
mazeFile[i][j]= fr.;
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire