/** *
* PacmanFileReader.java * * Revisions: 1.0 Nov. 24, 2002 * Created the PacmanFileReader class * 1.1 Nov. 25, 2002 * Compiled, Finished, Done * ** * Collaboration statement: * I worked on this assignment with Roland Krystian Alberciak * * @author *Roland Krystian Alberciak *@author Jose Manuel Caban * @version Version 1.1, Nov. 25, 2002 */ import java.util.*; import java.io.*; public class PacmanFileReader { private GamePiece[][] pieceArray; private BufferedReader brReader; /** *Hold Pacman */ private Pacman cPacman; /** *Hold Ghosts */ private Ghost cGhost1; private Ghost cGhost2; private Ghost cGhost3; private Ghost cGhost4; /** *Constructor *@param inFile, the name of the file to read */ public PacmanFileReader(String inFile){ readMap(inFile); } /** *Take in the file and create a grid *@param mapFile, the file to be read */ private void readMap(String mapFile){ StringTokenizer st; ///////////////////// //Read Start Points// ///////////////////// try{ brReader = new BufferedReader(new FileReader(mapFile)); }catch(FileNotFoundException fnfe){ System.err.println("File Not Found Error - FileReader"); System.exit(0); } for(int i=0; i<5; i++){ st = new StringTokenizer("b"); try{ st = new StringTokenizer(brReader.readLine()); }catch(IOException ioe){ System.err.println(ioe); System.exit(0); } switch(i){ case 0: cPacman = new Pacman(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken())); break; case 1: cGhost1 = new Ghost(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()),1); break; case 2: cGhost2 = new Ghost(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()),2); break; case 3: cGhost3 = new Ghost(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()),3); break; case 4: cGhost4 = new Ghost(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()),4); break; } } /*End Read Start Points*/ ///////////////////////// String strTemp = ""; pieceArray = new GamePiece[15][15]; ////////////// /*Read in map*/ st = new StringTokenizer(""); for(int i=0; i