|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object smithers.logicpuzzles.Slitherlink
public class Slitherlink
Represents a slitherlink puzzle.
Constructor Summary | |
---|---|
Slitherlink(int[][] clues)
Constructs a puzzle from a grid of clues. |
|
Slitherlink(int height,
int width)
Constructs a blank puzzle of the specified size. |
Method Summary | |
---|---|
int |
getClue(int row,
int column)
Gets the clue for the specified cell. |
int |
getHeight()
Gets the height of the puzzle. |
int |
getWidth()
Gets the width of the puzzle. |
boolean |
isMutable()
Checks whether this puzzle can be modified. |
static Slitherlink |
load(java.io.File file)
Loads a puzzle from a file. |
static void |
main(java.lang.String[] args)
|
Slitherlink |
makeImmutableCopy()
Creates a copy of this puzzle which cannot be modified further. |
void |
save(java.io.File file)
Saves the puzzle to a file. |
void |
setClue(int row,
int column,
int clue)
Sets the clue for the specified cell. |
java.lang.String |
toString()
Generates a String representing the puzzle's clues. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Slitherlink(int height, int width)
height
- the height of the puzzlewidth
- the width of the puzzle
java.lang.IllegalArgumentException
- if the width or height are negativepublic Slitherlink(int[][] clues)
clues
- an array of the clues, with -1 representing no clue
java.lang.IllegalArgumentException
- if any of the clues are out of rangeMethod Detail |
---|
public static Slitherlink load(java.io.File file) throws java.io.IOException
file
- the file to load from
java.io.IOException
- if one occurspublic void save(java.io.File file) throws java.io.IOException
file
- the file to save to
java.io.IOException
- if one occurspublic boolean isMutable()
Puzzle
isMutable
in interface Puzzle
true
iff this puzzle is mutablepublic Slitherlink makeImmutableCopy()
Puzzle
Puzzle
is used to construct a State
or Solver
, the constructer should call this method to get an
immutable copy. Copies created by this method should return false
to Puzzle.isMutable()
and throw ImmutablePuzzleException
when a method attempts to modify them.
makeImmutableCopy
in interface Puzzle
public int getHeight()
public int getWidth()
public int getClue(int row, int column)
row
- the row index (from 0)column
- the column index (from 0)
row
, column column
,
or -1
if the cell is blankpublic void setClue(int row, int column, int clue)
row
- the row index (from 0)column
- the column index (from 0)clue
- the clue to place in the cell, or -1
to clearpublic java.lang.String toString()
String
representing the puzzle's clues. Uses spaces
to represent no clue.
toString
in interface Puzzle
toString
in class java.lang.Object
String
representing the puzzlepublic static void main(java.lang.String[] args) throws java.io.IOException
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |