|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectgui.RushHourDomain
public class RushHourDomain
The domain of the Rush Hour GUI handles intermediate communication not directly with the GUI but imperative to GUI functionality. These methods can only be called by classes within the gui package and are helper methods to the GUIs functionality.
| Constructor Summary | |
|---|---|
RushHourDomain()
|
|
| Method Summary | |
|---|---|
static void |
loadGame(java.lang.Object file,
RushHourGameBoard gameBoard)
Loads a saved game from the given input file. |
static void |
recurseThroughSolution(java.util.Vector<java.lang.String> buildDirections,
java.util.HashMap<java.lang.String,java.lang.String> validMoves,
java.util.HashMap<java.lang.String,java.lang.String> directionsForValidMoves,
java.lang.String nextState)
Since the instructions will be in reverse order, recurse backward through all instructions and then add them to the vector of directions. |
static void |
saveGame(java.io.File file,
RushHourGameBoard gameBoard)
Saves the current game board to the specified file. |
static java.awt.Point |
simplifyPoint(java.awt.Point clicked,
int guiWidth,
int width,
int guiHeight,
int height)
Simplifies the three-digit (x, y) coordinate retrieved from a location on the GUI to a single-digit (x, y) coordinate that corresponds to coordinates within the game board object. |
static java.awt.Point |
unsimplifyPoint(java.awt.Point coordinates,
int guiWidth,
int width,
int guiHeight,
int height)
Unsimplifies the single-digit (x, y) coordinate retrieved from a coordinate within the game board object to a three-digit (x, y) location that corresponds to the GUI. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RushHourDomain()
| Method Detail |
|---|
public static void loadGame(java.lang.Object file,
RushHourGameBoard gameBoard)
throws RushHourException,
java.io.IOException,
java.lang.NumberFormatException
file - The file to be read from.gameBoard - The empty game board to load into.
RushHourException - A characteristic of the vehicle given in
the data file is invalid.
java.lang.ArrayIndexOutOfBoundsException - The coordinate given in the data
file for placing this vehicle is invalid.
java.io.IOException - An error occured when reading the next line from the
data file.
java.lang.NumberFormatException - A number given in the data file was not an
integer greater than zero.
public static void saveGame(java.io.File file,
RushHourGameBoard gameBoard)
throws java.io.IOException
file - The file to be written to.gameBoard - The game board to be written to the file.
java.io.IOException - An error occured when reading the next line from the
data file.
public static void recurseThroughSolution(java.util.Vector<java.lang.String> buildDirections,
java.util.HashMap<java.lang.String,java.lang.String> validMoves,
java.util.HashMap<java.lang.String,java.lang.String> directionsForValidMoves,
java.lang.String nextState)
buildDirections - The vector that the directions will be added to for
output to the console.validMoves - The hash map that contains board states for attaining
valid moves.directionsForValidMoves - The hash map that contains directions
for valid moves.nextState - The next state to follow on the hash map.
public static java.awt.Point unsimplifyPoint(java.awt.Point coordinates,
int guiWidth,
int width,
int guiHeight,
int height)
coordinates - The single-digit point from the GUI.guiWidth - The width of the GUI board.width - The width of the board.
param guiHeight the height of the GUI board.height - The height of the board.
public static java.awt.Point simplifyPoint(java.awt.Point clicked,
int guiWidth,
int width,
int guiHeight,
int height)
clicked - The three-digit point from the GUI.guiWidth - The width of the GUI board.width - The width of the board.
param guiHeight the height of the GUI board.height - The height of the board.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||