smithers.twisty
Interface TwistyPuzzle

All Known Subinterfaces:
AnimatedTwistyPuzzle, StickerSwappingTwistyPuzzle
All Known Implementing Classes:
RubiksCube, Snake, SquareOne

public interface TwistyPuzzle

Represents a twisty puzzle such as a Rubik's Cube. In all of the methods in this, a sticker index uniquely determines a sticker, not a location. That is, after a twist is made, the getColor(int) method should return the same values as before, but getPolygon(int) method will not. If a puzzle has unstickered faces, it should declare those as having stickers with a transparent colour.


Method Summary
 int getColor(int index)
          Gets the colour of the specified sticker.
 Polygon3D getPolygon(int index)
          Gets the 3-d polygon associated with the specified sticker.
 double getScale()
          Returns the absolute scale of the 3-d model of the puzzle.
 Twist getTwist(int index, int dir)
          Gets the twist instance determined by the sticker clicked on, and the directon to twist.
 boolean isSolved()
          Works out whether this puzzle is in the solved state.
 void scramble()
          Scrambles the puzzle.
 int stickerCount()
          Gets the number of stickers on the puzzle.
 void twist(Twist twist)
          Applies a twist.
 

Method Detail

stickerCount

int stickerCount()
Gets the number of stickers on the puzzle.

Returns:
the number of stickers

getColor

int getColor(int index)
Gets the colour of the specified sticker. The colour returned is specified as ARGB.

Parameters:
index - the sticker index
Returns:
the colour of the sticker

getScale

double getScale()
Returns the absolute scale of the 3-d model of the puzzle. Essentially, this should return the recommended 3-d width of the viewing window.

Returns:
the scale

getPolygon

Polygon3D getPolygon(int index)
Gets the 3-d polygon associated with the specified sticker.

Parameters:
index - the sticker index
Returns:
the polygon of the sticker

getTwist

Twist getTwist(int index,
               int dir)
Gets the twist instance determined by the sticker clicked on, and the directon to twist. This should always return an instance which will be accepted by twist(smithers.twisty.Twist) (i.e. will not throw ClassCastException, although the move may not be possible). The dir argument should be: 0 for anticlockwise, 1 for clockwise or 2 for a half twist.

Parameters:
index - the sticker which was clicked on
dir - the directon
Returns:
the twist instance

twist

void twist(Twist twist)
Applies a twist.

Parameters:
twist - the twist

scramble

void scramble()
Scrambles the puzzle.


isSolved

boolean isSolved()
Works out whether this puzzle is in the solved state.

Returns:
true iff the puzzle is solved