public class RubiksCube
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected ColorsEnum[][] |
elements
Array that contains the colors of each element.
|
int |
MAXSOLLENGTH
Maximum length of solution that can be safed.
|
private boolean |
recording
While recording is true every move on the cube is saved to the solution array.
|
private int |
rotations
Number of 90 degrees rotations (used to determine Rubik's cube's orientation).
|
AllMoves[] |
solution
Solution array that contains all performed moves and the final solution after removing redundancy.
|
int |
solutionIndex
Index of next empty element in solution array (current element that can be written to).
|
Constructor and Description |
---|
RubiksCube()
Constructor that initializes cube in NULL-state.
|
RubiksCube(AllMoves[] maneuver)
Constructor that initializes cube in solved-state and applies given maneuver to cube.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
allEdgesOriented()
Returns true if all edges of middle horizontal plane are correctly oriented.
|
protected void |
applyMoves(AllMoves[] moves)
Apply given moves to cube-representation.
|
protected ColorsEnum |
backColor()
Returns current color of back face.
|
protected boolean |
completeIntegrity()
Checks if every color exists exactly 8 times in cube-representation.
|
protected void |
down()
Apply clockwise rotation to down face of cube-representation.
|
protected ColorsEnum |
downColor()
Returns color of down face (this is static).
|
private void |
downInverted()
Apply counter clockwise rotation to down face of cube-representation.
|
private void |
front()
Apply clockwise rotation to front face of cube-representation.
|
protected ColorsEnum |
frontColor()
Returns current color of front face.
|
private void |
frontInverted()
Apply counter clockwise rotation to front face of cube-representation.
|
protected boolean |
frtCornerOriented()
Returns true if front right up corner is correctly oriented.
|
protected boolean |
ftEdgeOriented()
Returns true if front up edge is correctly oriented.
|
protected Corner |
getCorner(int i)
Method returns Corner object.
|
protected Edge |
getEdge(int i)
Method returns Edge object.
|
protected boolean |
getRecording()
Getter-method for boolean variable "recording"
|
protected boolean |
isSolved()
Returns true when cube-representation is in solved-state.
|
protected ColorsEnum |
leftColor()
Returns current color of left face.
|
protected boolean |
leftEdgeOriented()
Returns true if front left edge is correctly oriented.
|
protected void |
print()
Print elements of cube-representation to std.out.
|
protected void |
printEV3()
Print elements of cube-representation to EV3-Display.
|
protected void |
resetNull()
Reset cube-representation to NULL-state.
|
protected void |
resetScrambled(int length)
Reset cube-representation to randomly scrambled state.
|
protected void |
resetSolved()
Reset cube-representation to solved-state.
|
protected ColorsEnum |
rightColor()
Returns current color of right face.
|
protected boolean |
rightEdgeOriented()
Returns true if front right edge is correctly oriented.
|
protected void |
rotate()
Rotate cube-representation by 90 degrees clockwise (looking at down face).
|
private void |
rotateInverted()
Rotate cube-representation by 90 degrees counter clockwise (looking at down face).
|
protected void |
setRecording(boolean rec)
Setter-method for boolean variable "recording"
|
protected void |
setTopFace(ColorsEnum[] scannedFace)
Writes colors from given array into top face of cube-representation (the elememts-array).
|
protected void |
shortenSolution()
Removes redundancy from solution array.
|
private void |
turnFace(FacesEnum face)
Helper-method for applying clockwise rotations to a cube's face.
|
private void |
turnFaceInverted(FacesEnum face)
Helper-method for applying counter clockwise rotations to a cube's face.
|
protected ColorsEnum |
upColor()
Returns color of up face (this is static).
|
protected ColorsEnum[][] elements
public final int MAXSOLLENGTH
private int rotations
private boolean recording
public int solutionIndex
public AllMoves[] solution
public RubiksCube()
public RubiksCube(AllMoves[] maneuver)
maneuver
- maneuver to apply to cube after initialization.protected void setRecording(boolean rec)
rec
- boolean value to write in "recording"protected boolean getRecording()
protected Edge getEdge(int i)
i
- Number of Edge to return (Rubik's cube has 12 edges).protected Corner getCorner(int i)
i
- Number of corner to return (Rubik's Cube has 8 corners).private void turnFaceInverted(FacesEnum face)
face
- Face to rotate.private void turnFace(FacesEnum face)
face
- Face to rotate.private void front()
private void frontInverted()
protected void down()
private void downInverted()
protected void rotate()
private void rotateInverted()
protected void resetSolved()
protected void resetNull()
protected void resetScrambled(int length)
length
- Length of randomly generated maneuver that is applied to scramble the cube.protected void setTopFace(ColorsEnum[] scannedFace)
scannedFace
- protected void applyMoves(AllMoves[] moves)
moves
- Array that contains moves to apply to cube.protected void print()
protected void printEV3()
protected boolean isSolved()
protected boolean completeIntegrity()
protected ColorsEnum leftColor()
protected ColorsEnum frontColor()
protected ColorsEnum rightColor()
protected ColorsEnum backColor()
protected ColorsEnum upColor()
protected ColorsEnum downColor()
protected boolean ftEdgeOriented()
protected boolean frtCornerOriented()
protected boolean leftEdgeOriented()
protected boolean rightEdgeOriented()
protected boolean allEdgesOriented()
protected void shortenSolution()