|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectPuzzleLoader
public class PuzzleLoader
PuzzleLoader reads and processes a puzzle definition file. The resulting puzzle object and error messages are available through accessors. For a description of the file format, please see the assignment description.
Field Summary | |
---|---|
private java.util.ArrayList |
errors
|
private java.lang.String |
fileName
|
private Puzzle |
puzzle
|
Constructor Summary | |
---|---|
PuzzleLoader(java.lang.String fileName)
Constructor: reads a puzzle definition from the file with the specified file name and creates a puzzle object from it, warnings and error are stored in the object. |
Method Summary | |
---|---|
java.util.List |
getErrors()
Accessor for the list of errors that were generated when reading the file. |
java.lang.String |
getFileName()
Accessor for file name string |
Puzzle |
getPuzzle()
Accessor for loaded puzzle |
private static Piece |
readPiece(java.io.BufferedReader reader)
Reads a line, processes it, and returns a new Piece object |
private void |
readPuzzle(java.io.BufferedReader reader)
Reads puzzle definition and creates a puzzle state object with pieces |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Puzzle puzzle
private java.util.ArrayList errors
private java.lang.String fileName
Constructor Detail |
---|
public PuzzleLoader(java.lang.String fileName)
fileName
- name of a file from which to read a puzzle definitionMethod Detail |
---|
private void readPuzzle(java.io.BufferedReader reader) throws PuzzleException, java.io.IOException
reader
- the source of the line
PuzzleException
- if the file doesn't define a valid puzzle
java.io.IOException
- if the file cannot be readprivate static Piece readPiece(java.io.BufferedReader reader) throws java.io.IOException, java.io.EOFException, PuzzleException
reader
- the source of the line
java.io.IOException
- if the line cannot be read
java.io.EOFException
- when the end of the file is reached
PuzzleException
- if the line contains an invalid piece definitionpublic java.lang.String getFileName()
public Puzzle getPuzzle()
public java.util.List getErrors()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |