Uses of Class
api.State
-
Packages that use State Package Description api hw3 -
-
Uses of State in api
Methods in api that return State Modifier and Type Method Description static State[]
StringUtil. createFromString(java.lang.String text)
Creates a cell state array from a string description, using the character representations defined in this class.State
Cell. getState()
Returns the state for this cell.State
MoveRecord. getState()
Returns the state in this MoveRecord.static State
StringUtil. getValue(char c)
Returns the State corresponding to the given character, if possible.static State
State. valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static State[]
State. values()
Returns an array containing the constants of this enum type, in the order they are declared.Methods in api with parameters of type State Modifier and Type Method Description static boolean
State. canMerge(State s1, State s2)
Returns true if both given states are movable and have opposite parity.static char
StringUtil. getChar(State s)
Returns the basic character for a state.static boolean
State. isBoundary(State s, boolean containsMovable)
Determines whether the given state should be considered a boundary when constructing a state sequence for a move.static boolean
State. isMovable(State s)
Returns true if the given state represents a movable block.static boolean
State. isSpikes(State s)
Returns true if the given state is some form of spikes.static void
StringUtil. printStateArray(State[] states, int playerIndex)
Prints an array of States using the character representations defined in this class.void
Cell. setState(State givenState)
Sets the state for this cell.static boolean
State. spikesAreDeadly(State s, Direction dir)
Returns true if the given state is spikes pointing in the direction opposite the givenDirection
, or if the given state is SPIKES_ALL.static java.lang.String
StringUtil. toString(State[] arr)
Converts a state array to a string representation, using the character representations defined in this class, with an extra space inserted between characters.static java.lang.String
StringUtil. toString(State[] arr, boolean addSpaces)
Converts a state array to a string representation, using the character representations defined in this class, where an extra space is optionally inserted between characters.static java.lang.String
StringUtil. toString(State[] arr, int playerIndex)
Converts a cell state array to a string representation, using the character representations defined in this class, including the player position.Constructors in api with parameters of type State Constructor Description Cell(State givenState)
Constructs a Cell with the given state.MoveRecord(State givenState, int currentIndex)
Constructs a MoveRecord from the given State and index. -
Uses of State in hw3
Methods in hw3 that return State Modifier and Type Method Description State[]
Pearls. getStateSequence(Direction dir)
Finds a valid state sequence in the given direction starting with the player's current position and ending with a boundary cell as defined by the methodState.isBoundary
.Methods in hw3 with parameters of type State Modifier and Type Method Description void
PearlUtil. collectPearls(State[] states, MoveRecord[] records, int start, int end)
Replaces all PEARL states with EMPTY state between indices start and end, inclusive.int
PearlUtil. findRightmostMovableBlock(State[] states, int start)
Returns the index of the rightmost movable block that is at or to the left of the given indexstart
.static boolean
PearlUtil. isValidForMoveBlocks(State[] states)
Determines whether the given state sequence is valid for the moveBlocks method.void
PearlUtil. moveBlocks(State[] states, MoveRecord[] records)
Updates the given state sequence to be consistent with shifting all movable blocks as far to the right as possible, replacing their previous positions with EMPTY.int
PearlUtil. movePlayer(State[] states, MoveRecord[] records, Direction dir)
Updates the given state sequence to be consistent with shifting the "player" to the right as far as possible.void
Pearls. setStateSequence(State[] states, Direction dir, int playerIndex)
Sets the given state sequence and updates the player position.
-