smithers.logicpuzzles
Class HanjieState

java.lang.Object
  extended by smithers.logicpuzzles.HanjieState
All Implemented Interfaces:
PuzzleState<Hanjie>

public class HanjieState
extends java.lang.Object
implements PuzzleState<Hanjie>

Class to store the state of a hanjie puzzle.


Constructor Summary
HanjieState(Hanjie puzzle)
          Constructs new solver for the specified puzzle.
 
Method Summary
 void clearState()
          Clears the state of the puzzle.
 Hanjie getPuzzle()
          Returns the puzzle which this is a state of.
 int getState(int row, int column)
          Gets the state of a specificate pixel.
 boolean isSolved()
          Determines whether or not the puzzle has been completely solved.
 void setState(int row, int column, int state)
          Adds to the attempt at solving the puzzle.
 java.lang.String toString()
          Generates a String representing the current situation of the puzzle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HanjieState

public HanjieState(Hanjie puzzle)
Constructs new solver for the specified puzzle.

Parameters:
puzzle - the puzzle
Method Detail

getPuzzle

public Hanjie getPuzzle()
Description copied from interface: PuzzleState
Returns the puzzle which this is a state of.

Specified by:
getPuzzle in interface PuzzleState<Hanjie>
Returns:
the Puzzle which this PuzzleState relates to.

getState

public int getState(int row,
                    int column)
Gets the state of a specificate pixel.

Parameters:
row - the row index (from 0)
column - the column index (from 0)
Returns:
the state of the pixel in row row, column column

setState

public void setState(int row,
                     int column,
                     int state)
Adds to the attempt at solving the puzzle.

Parameters:
row - the row index (from 0)
column - the column index (from 0)
state - the index of the colour to set coloured, 0 for not coloured, or -1 to reset

clearState

public void clearState()
Clears the state of the puzzle.


isSolved

public boolean isSolved()
Description copied from interface: PuzzleState
Determines whether or not the puzzle has been completely solved.

Specified by:
isSolved in interface PuzzleState<Hanjie>
Returns:
true iff the puzzle has been completely solved

toString

public java.lang.String toString()
Generates a String representing the current situation of the puzzle. Represents unknown as a grave accent '`', white (unfilled) as a space ' ' and colour 1 as a hash '#'. In colour puzzles, for i>1 it represents colour i as (char)(0x0022+i), i.e. Unicode characters continuing from '#'.

Specified by:
toString in interface PuzzleState<Hanjie>
Overrides:
toString in class java.lang.Object
Returns:
a String representing the state