From ab997e652f4083b865c647953951f2e48e4b1ac4 Mon Sep 17 00:00:00 2001 From: AndrDia Date: Tue, 3 Feb 2026 17:06:10 +0300 Subject: [PATCH 1/8] test front & back --- .../hse/java/practice/task1/RubiksCube.java | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/src/main/java/hse/java/practice/task1/RubiksCube.java b/src/main/java/hse/java/practice/task1/RubiksCube.java index 2091b657..279b987e 100644 --- a/src/main/java/hse/java/practice/task1/RubiksCube.java +++ b/src/main/java/hse/java/practice/task1/RubiksCube.java @@ -26,9 +26,84 @@ public RubiksCube() { } } + private void RotateItself(RotateDirection direction, Integer s) { + if (direction == RotateDirection.CLOCKWISE) { + CubeColor tmp = edges[s].getParts()[0][0]; + edges[s].getParts()[0][0] = edges[s].getParts()[2][0]; + edges[s].getParts()[2][0] = edges[s].getParts()[2][2]; + edges[s].getParts()[2][2] = edges[s].getParts()[0][2]; + edges[s].getParts()[0][2] = tmp; + tmp = edges[s].getParts()[0][1]; + edges[s].getParts()[0][1] = edges[s].getParts()[1][0]; + edges[s].getParts()[1][0] = edges[s].getParts()[2][1]; + edges[s].getParts()[2][1] = edges[s].getParts()[1][2]; + edges[s].getParts()[1][2] = tmp; + } + else if (direction == RotateDirection.COUNTERCLOCKWISE) { + CubeColor tmp = edges[s].getParts()[0][0]; + edges[s].getParts()[0][0] = edges[s].getParts()[0][2]; + edges[s].getParts()[0][2] = edges[s].getParts()[2][2]; + edges[s].getParts()[2][2] = edges[s].getParts()[2][0]; + edges[s].getParts()[2][0] = tmp; + tmp = edges[s].getParts()[0][1]; + edges[s].getParts()[0][1] = edges[s].getParts()[1][2]; + edges[s].getParts()[1][2] = edges[s].getParts()[2][1]; + edges[s].getParts()[2][1] = edges[s].getParts()[1][0]; + edges[s].getParts()[1][0] = tmp; + } + } + public void front(RotateDirection direction) { + RotateItself(direction, 4); + if (direction == RotateDirection.CLOCKWISE) { + CubeColor[] up_color = edges[0].getParts()[2].clone(); + for (int i = 0; i < 3; i++) { + edges[0].getParts()[2][i] = edges[2].getParts()[2 - i][2]; + edges[2].getParts()[2 - i][2] = edges[1].getParts()[0][2 - i]; + edges[1].getParts()[0][2 - i] = edges[3].getParts()[i][0]; + edges[3].getParts()[i][0] = up_color[i]; + } + } + else if (direction == RotateDirection.COUNTERCLOCKWISE) { + CubeColor[] up_color = edges[0].getParts()[2].clone(); + for (int i = 0; i < 3; i++) { + edges[0].getParts()[2][i] = edges[3].getParts()[i][0]; + edges[3].getParts()[i][0] = edges[1].getParts()[0][2-i]; + edges[1].getParts()[0][2-i] = edges[2].getParts()[2-i][2]; + edges[2].getParts()[2-i][2] = up_color[i]; + } + } + } + + public void back(RotateDirection direction) { + RotateItself(direction, 5); + if (direction == RotateDirection.CLOCKWISE) { + CubeColor[] up_color = edges[0].getParts()[0].clone(); + for (int i = 0; i < 3; i++) { + edges[0].getParts()[0][i] = edges[3].getParts()[i][2]; + edges[3].getParts()[i][2] = edges[1].getParts()[2][2-i]; + edges[1].getParts()[2][2-i] = edges[2].getParts()[2-i][0]; + edges[2].getParts()[2-i][0] = up_color[i]; + } + } + else if (direction == RotateDirection.COUNTERCLOCKWISE) { + CubeColor[] up_color = edges[0].getParts()[0].clone() ; + for (int i = 0; i < 3; i++) { + edges[0].getParts()[0][i] = edges[2].getParts()[2-i][0]; + edges[2].getParts()[2-i][0] = edges[1].getParts()[2][2-i]; + edges[1].getParts()[2][2-i] = edges[3].getParts()[i][2]; + edges[3].getParts()[i][2] = up_color[i]; + } + } + } + public void up(RotateDirection direction) { + RotateItself(direction, 0); } + + public void left(RotateDirection direction) {} + public void right(RotateDirection direction) {} + public void down(RotateDirection direction) {} public Edge[] getEdges() { return edges; From a5ce1ecf9e6e3c9642f8525abde7491a888ffa63 Mon Sep 17 00:00:00 2001 From: AndrDia Date: Tue, 3 Feb 2026 17:59:15 +0300 Subject: [PATCH 2/8] test up & down --- .../hse/java/practice/task1/RubiksCube.java | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/main/java/hse/java/practice/task1/RubiksCube.java b/src/main/java/hse/java/practice/task1/RubiksCube.java index 279b987e..9f04d80f 100644 --- a/src/main/java/hse/java/practice/task1/RubiksCube.java +++ b/src/main/java/hse/java/practice/task1/RubiksCube.java @@ -99,11 +99,51 @@ else if (direction == RotateDirection.COUNTERCLOCKWISE) { public void up(RotateDirection direction) { RotateItself(direction, 0); + if (direction == RotateDirection.CLOCKWISE) { + CubeColor[] front_color = edges[0].getParts()[0].clone(); + for (int i = 0; i < 3; i++) { + edges[0].getParts()[0][i] = edges[3].getParts()[0][i]; + edges[3].getParts()[0][i] = edges[5].getParts()[0][i]; + edges[5].getParts()[0][i] = edges[2].getParts()[0][i]; + edges[2].getParts()[0][i] = front_color[i]; + } + } + else if (direction == RotateDirection.COUNTERCLOCKWISE) { + CubeColor[] front_color = edges[0].getParts()[0].clone() ; + for (int i = 0; i < 3; i++) { + edges[0].getParts()[0][i] = edges[2].getParts()[0][i]; + edges[2].getParts()[0][i] = edges[5].getParts()[0][2-i]; + edges[5].getParts()[0][2-i] = edges[3].getParts()[0][2-i]; + edges[3].getParts()[0][2-i] = front_color[2-i]; + } + } + } + + public void down(RotateDirection direction) { + RotateItself(direction, 1); + if (direction == RotateDirection.CLOCKWISE) { + CubeColor[] front_color = edges[0].getParts()[2].clone(); + for (int i = 0; i < 3; i++) { + edges[0].getParts()[2][i] = edges[3].getParts()[2][i]; + edges[3].getParts()[2][i] = edges[5].getParts()[2][i]; + edges[5].getParts()[2][i] = edges[2].getParts()[2][i]; + edges[2].getParts()[2][i] = front_color[i]; + } + } + else if (direction == RotateDirection.COUNTERCLOCKWISE) { + CubeColor[] front_color = edges[0].getParts()[2].clone() ; + for (int i = 0; i < 3; i++) { + edges[0].getParts()[2][i] = edges[2].getParts()[2][i]; + edges[2].getParts()[2][i] = edges[5].getParts()[2][2-i]; + edges[5].getParts()[2][2-i] = edges[3].getParts()[2][2-i]; + edges[3].getParts()[2][2-i] = front_color[2-i]; + } + } } public void left(RotateDirection direction) {} public void right(RotateDirection direction) {} - public void down(RotateDirection direction) {} + public Edge[] getEdges() { return edges; From a4676d89f5ee819efbe15bee20d91a52fff81daf Mon Sep 17 00:00:00 2001 From: AndrDia Date: Tue, 3 Feb 2026 18:08:25 +0300 Subject: [PATCH 3/8] up & down fix --- .../java/hse/java/practice/task1/RubiksCube.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/hse/java/practice/task1/RubiksCube.java b/src/main/java/hse/java/practice/task1/RubiksCube.java index 9f04d80f..1bba80c5 100644 --- a/src/main/java/hse/java/practice/task1/RubiksCube.java +++ b/src/main/java/hse/java/practice/task1/RubiksCube.java @@ -100,18 +100,18 @@ else if (direction == RotateDirection.COUNTERCLOCKWISE) { public void up(RotateDirection direction) { RotateItself(direction, 0); if (direction == RotateDirection.CLOCKWISE) { - CubeColor[] front_color = edges[0].getParts()[0].clone(); + CubeColor[] front_color = edges[4].getParts()[0].clone(); for (int i = 0; i < 3; i++) { - edges[0].getParts()[0][i] = edges[3].getParts()[0][i]; + edges[4].getParts()[0][i] = edges[3].getParts()[0][i]; edges[3].getParts()[0][i] = edges[5].getParts()[0][i]; edges[5].getParts()[0][i] = edges[2].getParts()[0][i]; edges[2].getParts()[0][i] = front_color[i]; } } else if (direction == RotateDirection.COUNTERCLOCKWISE) { - CubeColor[] front_color = edges[0].getParts()[0].clone() ; + CubeColor[] front_color = edges[4].getParts()[0].clone() ; for (int i = 0; i < 3; i++) { - edges[0].getParts()[0][i] = edges[2].getParts()[0][i]; + edges[4].getParts()[0][i] = edges[2].getParts()[0][i]; edges[2].getParts()[0][i] = edges[5].getParts()[0][2-i]; edges[5].getParts()[0][2-i] = edges[3].getParts()[0][2-i]; edges[3].getParts()[0][2-i] = front_color[2-i]; @@ -122,18 +122,18 @@ else if (direction == RotateDirection.COUNTERCLOCKWISE) { public void down(RotateDirection direction) { RotateItself(direction, 1); if (direction == RotateDirection.CLOCKWISE) { - CubeColor[] front_color = edges[0].getParts()[2].clone(); + CubeColor[] front_color = edges[4].getParts()[2].clone(); for (int i = 0; i < 3; i++) { - edges[0].getParts()[2][i] = edges[3].getParts()[2][i]; + edges[4].getParts()[2][i] = edges[3].getParts()[2][i]; edges[3].getParts()[2][i] = edges[5].getParts()[2][i]; edges[5].getParts()[2][i] = edges[2].getParts()[2][i]; edges[2].getParts()[2][i] = front_color[i]; } } else if (direction == RotateDirection.COUNTERCLOCKWISE) { - CubeColor[] front_color = edges[0].getParts()[2].clone() ; + CubeColor[] front_color = edges[4].getParts()[2].clone() ; for (int i = 0; i < 3; i++) { - edges[0].getParts()[2][i] = edges[2].getParts()[2][i]; + edges[4].getParts()[2][i] = edges[2].getParts()[2][i]; edges[2].getParts()[2][i] = edges[5].getParts()[2][2-i]; edges[5].getParts()[2][2-i] = edges[3].getParts()[2][2-i]; edges[3].getParts()[2][2-i] = front_color[2-i]; From ea61329c05331cf2fa9819f41a3ac6dbe951105f Mon Sep 17 00:00:00 2001 From: AndrDia Date: Tue, 3 Feb 2026 18:24:14 +0300 Subject: [PATCH 4/8] up & down test --- .../hse/java/practice/task1/RubiksCube.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/hse/java/practice/task1/RubiksCube.java b/src/main/java/hse/java/practice/task1/RubiksCube.java index 1bba80c5..fda841b7 100644 --- a/src/main/java/hse/java/practice/task1/RubiksCube.java +++ b/src/main/java/hse/java/practice/task1/RubiksCube.java @@ -112,9 +112,9 @@ else if (direction == RotateDirection.COUNTERCLOCKWISE) { CubeColor[] front_color = edges[4].getParts()[0].clone() ; for (int i = 0; i < 3; i++) { edges[4].getParts()[0][i] = edges[2].getParts()[0][i]; - edges[2].getParts()[0][i] = edges[5].getParts()[0][2-i]; - edges[5].getParts()[0][2-i] = edges[3].getParts()[0][2-i]; - edges[3].getParts()[0][2-i] = front_color[2-i]; + edges[2].getParts()[0][i] = edges[5].getParts()[0][i]; + edges[5].getParts()[0][i] = edges[3].getParts()[0][i]; + edges[3].getParts()[0][i] = front_color[i]; } } } @@ -124,19 +124,19 @@ public void down(RotateDirection direction) { if (direction == RotateDirection.CLOCKWISE) { CubeColor[] front_color = edges[4].getParts()[2].clone(); for (int i = 0; i < 3; i++) { - edges[4].getParts()[2][i] = edges[3].getParts()[2][i]; - edges[3].getParts()[2][i] = edges[5].getParts()[2][i]; - edges[5].getParts()[2][i] = edges[2].getParts()[2][i]; - edges[2].getParts()[2][i] = front_color[i]; + edges[4].getParts()[2][i] = edges[2].getParts()[2][i]; + edges[2].getParts()[2][i] = edges[5].getParts()[2][i]; + edges[5].getParts()[2][i] = edges[3].getParts()[2][i]; + edges[3].getParts()[2][i] = front_color[i]; } } else if (direction == RotateDirection.COUNTERCLOCKWISE) { CubeColor[] front_color = edges[4].getParts()[2].clone() ; for (int i = 0; i < 3; i++) { - edges[4].getParts()[2][i] = edges[2].getParts()[2][i]; - edges[2].getParts()[2][i] = edges[5].getParts()[2][2-i]; - edges[5].getParts()[2][2-i] = edges[3].getParts()[2][2-i]; - edges[3].getParts()[2][2-i] = front_color[2-i]; + edges[4].getParts()[2][i] = edges[3].getParts()[2][i]; + edges[2].getParts()[2][i] = edges[5].getParts()[2][i]; + edges[5].getParts()[2][i] = edges[3].getParts()[2][i]; + edges[3].getParts()[2][i] = front_color[i]; } } } From a84629d30a2b119c6e51b69762f5e7afd6d09934 Mon Sep 17 00:00:00 2001 From: AndrDia Date: Tue, 3 Feb 2026 19:00:11 +0300 Subject: [PATCH 5/8] test left & right --- .../hse/java/practice/task1/RubiksCube.java | 68 ++++++++++++++++--- 1 file changed, 60 insertions(+), 8 deletions(-) diff --git a/src/main/java/hse/java/practice/task1/RubiksCube.java b/src/main/java/hse/java/practice/task1/RubiksCube.java index fda841b7..79ef0563 100644 --- a/src/main/java/hse/java/practice/task1/RubiksCube.java +++ b/src/main/java/hse/java/practice/task1/RubiksCube.java @@ -54,7 +54,7 @@ else if (direction == RotateDirection.COUNTERCLOCKWISE) { } public void front(RotateDirection direction) { - RotateItself(direction, 4); + RotateItself(direction,4); if (direction == RotateDirection.CLOCKWISE) { CubeColor[] up_color = edges[0].getParts()[2].clone(); for (int i = 0; i < 3; i++) { @@ -76,7 +76,7 @@ else if (direction == RotateDirection.COUNTERCLOCKWISE) { } public void back(RotateDirection direction) { - RotateItself(direction, 5); + RotateItself(direction,5); if (direction == RotateDirection.CLOCKWISE) { CubeColor[] up_color = edges[0].getParts()[0].clone(); for (int i = 0; i < 3; i++) { @@ -98,7 +98,7 @@ else if (direction == RotateDirection.COUNTERCLOCKWISE) { } public void up(RotateDirection direction) { - RotateItself(direction, 0); + RotateItself(direction,0); if (direction == RotateDirection.CLOCKWISE) { CubeColor[] front_color = edges[4].getParts()[0].clone(); for (int i = 0; i < 3; i++) { @@ -120,7 +120,7 @@ else if (direction == RotateDirection.COUNTERCLOCKWISE) { } public void down(RotateDirection direction) { - RotateItself(direction, 1); + RotateItself(direction,1); if (direction == RotateDirection.CLOCKWISE) { CubeColor[] front_color = edges[4].getParts()[2].clone(); for (int i = 0; i < 3; i++) { @@ -135,16 +135,68 @@ else if (direction == RotateDirection.COUNTERCLOCKWISE) { for (int i = 0; i < 3; i++) { edges[4].getParts()[2][i] = edges[3].getParts()[2][i]; edges[2].getParts()[2][i] = edges[5].getParts()[2][i]; - edges[5].getParts()[2][i] = edges[3].getParts()[2][i]; + edges[5].getParts()[2][i] = edges[2].getParts()[2][i]; edges[3].getParts()[2][i] = front_color[i]; } } } - public void left(RotateDirection direction) {} - public void right(RotateDirection direction) {} + public void left(RotateDirection direction) { + RotateItself(direction,2); + if (direction == RotateDirection.CLOCKWISE) { + CubeColor[] front_color = new CubeColor[3]; + for (int i = 0; i < 3; i++) { + front_color[i] = edges[4].getParts()[i][0]; + } + for (int i = 0; i < 3; i++) { + edges[4].getParts()[i][0] = edges[0].getParts()[i][0]; + edges[0].getParts()[i][0] = edges[5].getParts()[i][2]; + edges[5].getParts()[i][2] = edges[1].getParts()[i][2]; + edges[1].getParts()[i][2] = front_color[i]; + } + } + else if (direction == RotateDirection.COUNTERCLOCKWISE) { + CubeColor[] front_color = new CubeColor[3]; + for (int i = 0; i < 3; i++) { + front_color[i] = edges[4].getParts()[i][0]; + } + for (int i = 0; i < 3; i++) { + edges[4].getParts()[i][0] = edges[1].getParts()[2-i][2]; + edges[1].getParts()[2-i][2] = edges[5].getParts()[2-i][2]; + edges[5].getParts()[2-i][2] = edges[0].getParts()[i][0]; + edges[0].getParts()[i][0] = front_color[i]; + } + } + } + + public void right(RotateDirection direction) { + RotateItself(direction,3); + if (direction == RotateDirection.CLOCKWISE) { + CubeColor[] front_color = new CubeColor[3]; + for (int i = 0; i < 3; i++) { + front_color[i] = edges[4].getParts()[i][2]; + } + for (int i = 0; i < 3; i++) { + edges[4].getParts()[i][2] = edges[1].getParts()[2-i][0]; + edges[1].getParts()[2-i][0] = edges[5].getParts()[2-i][0]; + edges[5].getParts()[2-i][0] = edges[0].getParts()[i][2]; + edges[0].getParts()[i][2] = front_color[i]; + } + } + else if (direction == RotateDirection.COUNTERCLOCKWISE) { + CubeColor[] front_color = new CubeColor[3]; + for (int i = 0; i < 3; i++) { + front_color[i] = edges[4].getParts()[i][2]; + } + for (int i = 0; i < 3; i++) { + edges[4].getParts()[i][2] = edges[0].getParts()[i][2]; + edges[0].getParts()[i][2] = edges[5].getParts()[2-i][0]; + edges[5].getParts()[2-i][0] = edges[1].getParts()[2-i][0]; + edges[1].getParts()[2-i][0] = front_color[i]; + } + } + } - public Edge[] getEdges() { return edges; } From bd89e113ae134dc3a1c02ea7d2886da65b2e6eeb Mon Sep 17 00:00:00 2001 From: AndrDia Date: Tue, 3 Feb 2026 19:17:15 +0300 Subject: [PATCH 6/8] test left & right fix --- .../hse/java/practice/task1/RubiksCube.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/hse/java/practice/task1/RubiksCube.java b/src/main/java/hse/java/practice/task1/RubiksCube.java index 79ef0563..fde3607d 100644 --- a/src/main/java/hse/java/practice/task1/RubiksCube.java +++ b/src/main/java/hse/java/practice/task1/RubiksCube.java @@ -150,9 +150,9 @@ public void left(RotateDirection direction) { } for (int i = 0; i < 3; i++) { edges[4].getParts()[i][0] = edges[0].getParts()[i][0]; - edges[0].getParts()[i][0] = edges[5].getParts()[i][2]; - edges[5].getParts()[i][2] = edges[1].getParts()[i][2]; - edges[1].getParts()[i][2] = front_color[i]; + edges[0].getParts()[i][0] = edges[5].getParts()[2-i][2]; + edges[5].getParts()[2-i][2] = edges[1].getParts()[i][0]; + edges[1].getParts()[i][0] = front_color[i]; } } else if (direction == RotateDirection.COUNTERCLOCKWISE) { @@ -161,8 +161,8 @@ else if (direction == RotateDirection.COUNTERCLOCKWISE) { front_color[i] = edges[4].getParts()[i][0]; } for (int i = 0; i < 3; i++) { - edges[4].getParts()[i][0] = edges[1].getParts()[2-i][2]; - edges[1].getParts()[2-i][2] = edges[5].getParts()[2-i][2]; + edges[4].getParts()[i][0] = edges[1].getParts()[i][0]; + edges[1].getParts()[i][0] = edges[5].getParts()[2-i][2]; edges[5].getParts()[2-i][2] = edges[0].getParts()[i][0]; edges[0].getParts()[i][0] = front_color[i]; } @@ -177,8 +177,8 @@ public void right(RotateDirection direction) { front_color[i] = edges[4].getParts()[i][2]; } for (int i = 0; i < 3; i++) { - edges[4].getParts()[i][2] = edges[1].getParts()[2-i][0]; - edges[1].getParts()[2-i][0] = edges[5].getParts()[2-i][0]; + edges[4].getParts()[i][2] = edges[1].getParts()[i][2]; + edges[1].getParts()[i][2] = edges[5].getParts()[2-i][0]; edges[5].getParts()[2-i][0] = edges[0].getParts()[i][2]; edges[0].getParts()[i][2] = front_color[i]; } @@ -191,8 +191,8 @@ else if (direction == RotateDirection.COUNTERCLOCKWISE) { for (int i = 0; i < 3; i++) { edges[4].getParts()[i][2] = edges[0].getParts()[i][2]; edges[0].getParts()[i][2] = edges[5].getParts()[2-i][0]; - edges[5].getParts()[2-i][0] = edges[1].getParts()[2-i][0]; - edges[1].getParts()[2-i][0] = front_color[i]; + edges[5].getParts()[2-i][0] = edges[1].getParts()[i][2]; + edges[1].getParts()[i][2] = front_color[i]; } } } From 3e46fc8180e093fed75b83256c6e5c62252a2560 Mon Sep 17 00:00:00 2001 From: AndrDia Date: Tue, 3 Feb 2026 19:23:37 +0300 Subject: [PATCH 7/8] down Counterclockwise fix --- src/main/java/hse/java/practice/task1/RubiksCube.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/hse/java/practice/task1/RubiksCube.java b/src/main/java/hse/java/practice/task1/RubiksCube.java index fde3607d..76925a1e 100644 --- a/src/main/java/hse/java/practice/task1/RubiksCube.java +++ b/src/main/java/hse/java/practice/task1/RubiksCube.java @@ -134,9 +134,9 @@ else if (direction == RotateDirection.COUNTERCLOCKWISE) { CubeColor[] front_color = edges[4].getParts()[2].clone() ; for (int i = 0; i < 3; i++) { edges[4].getParts()[2][i] = edges[3].getParts()[2][i]; - edges[2].getParts()[2][i] = edges[5].getParts()[2][i]; + edges[3].getParts()[2][i] = edges[5].getParts()[2][i]; edges[5].getParts()[2][i] = edges[2].getParts()[2][i]; - edges[3].getParts()[2][i] = front_color[i]; + edges[2].getParts()[2][i] = front_color[i]; } } } From b0d683285097d7b7c3408e8d7712a5678e83753a Mon Sep 17 00:00:00 2001 From: AndrDia Date: Tue, 3 Feb 2026 19:28:53 +0300 Subject: [PATCH 8/8] delete extra --- .../hse/java/practice/task1/RubiksCube.java | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/main/java/hse/java/practice/task1/RubiksCube.java b/src/main/java/hse/java/practice/task1/RubiksCube.java index 76925a1e..26b94fd7 100644 --- a/src/main/java/hse/java/practice/task1/RubiksCube.java +++ b/src/main/java/hse/java/practice/task1/RubiksCube.java @@ -55,8 +55,10 @@ else if (direction == RotateDirection.COUNTERCLOCKWISE) { public void front(RotateDirection direction) { RotateItself(direction,4); + + CubeColor[] up_color = edges[0].getParts()[2].clone(); + if (direction == RotateDirection.CLOCKWISE) { - CubeColor[] up_color = edges[0].getParts()[2].clone(); for (int i = 0; i < 3; i++) { edges[0].getParts()[2][i] = edges[2].getParts()[2 - i][2]; edges[2].getParts()[2 - i][2] = edges[1].getParts()[0][2 - i]; @@ -65,7 +67,6 @@ public void front(RotateDirection direction) { } } else if (direction == RotateDirection.COUNTERCLOCKWISE) { - CubeColor[] up_color = edges[0].getParts()[2].clone(); for (int i = 0; i < 3; i++) { edges[0].getParts()[2][i] = edges[3].getParts()[i][0]; edges[3].getParts()[i][0] = edges[1].getParts()[0][2-i]; @@ -77,8 +78,10 @@ else if (direction == RotateDirection.COUNTERCLOCKWISE) { public void back(RotateDirection direction) { RotateItself(direction,5); + + CubeColor[] up_color = edges[0].getParts()[0].clone(); + if (direction == RotateDirection.CLOCKWISE) { - CubeColor[] up_color = edges[0].getParts()[0].clone(); for (int i = 0; i < 3; i++) { edges[0].getParts()[0][i] = edges[3].getParts()[i][2]; edges[3].getParts()[i][2] = edges[1].getParts()[2][2-i]; @@ -87,7 +90,6 @@ public void back(RotateDirection direction) { } } else if (direction == RotateDirection.COUNTERCLOCKWISE) { - CubeColor[] up_color = edges[0].getParts()[0].clone() ; for (int i = 0; i < 3; i++) { edges[0].getParts()[0][i] = edges[2].getParts()[2-i][0]; edges[2].getParts()[2-i][0] = edges[1].getParts()[2][2-i]; @@ -99,8 +101,10 @@ else if (direction == RotateDirection.COUNTERCLOCKWISE) { public void up(RotateDirection direction) { RotateItself(direction,0); + + CubeColor[] front_color = edges[4].getParts()[0].clone(); + if (direction == RotateDirection.CLOCKWISE) { - CubeColor[] front_color = edges[4].getParts()[0].clone(); for (int i = 0; i < 3; i++) { edges[4].getParts()[0][i] = edges[3].getParts()[0][i]; edges[3].getParts()[0][i] = edges[5].getParts()[0][i]; @@ -109,7 +113,6 @@ public void up(RotateDirection direction) { } } else if (direction == RotateDirection.COUNTERCLOCKWISE) { - CubeColor[] front_color = edges[4].getParts()[0].clone() ; for (int i = 0; i < 3; i++) { edges[4].getParts()[0][i] = edges[2].getParts()[0][i]; edges[2].getParts()[0][i] = edges[5].getParts()[0][i]; @@ -121,8 +124,10 @@ else if (direction == RotateDirection.COUNTERCLOCKWISE) { public void down(RotateDirection direction) { RotateItself(direction,1); + + CubeColor[] front_color = edges[4].getParts()[2].clone(); + if (direction == RotateDirection.CLOCKWISE) { - CubeColor[] front_color = edges[4].getParts()[2].clone(); for (int i = 0; i < 3; i++) { edges[4].getParts()[2][i] = edges[2].getParts()[2][i]; edges[2].getParts()[2][i] = edges[5].getParts()[2][i]; @@ -131,7 +136,6 @@ public void down(RotateDirection direction) { } } else if (direction == RotateDirection.COUNTERCLOCKWISE) { - CubeColor[] front_color = edges[4].getParts()[2].clone() ; for (int i = 0; i < 3; i++) { edges[4].getParts()[2][i] = edges[3].getParts()[2][i]; edges[3].getParts()[2][i] = edges[5].getParts()[2][i]; @@ -143,11 +147,13 @@ else if (direction == RotateDirection.COUNTERCLOCKWISE) { public void left(RotateDirection direction) { RotateItself(direction,2); + + CubeColor[] front_color = new CubeColor[3]; + for (int i = 0; i < 3; i++) { + front_color[i] = edges[4].getParts()[i][0]; + } + if (direction == RotateDirection.CLOCKWISE) { - CubeColor[] front_color = new CubeColor[3]; - for (int i = 0; i < 3; i++) { - front_color[i] = edges[4].getParts()[i][0]; - } for (int i = 0; i < 3; i++) { edges[4].getParts()[i][0] = edges[0].getParts()[i][0]; edges[0].getParts()[i][0] = edges[5].getParts()[2-i][2]; @@ -156,10 +162,6 @@ public void left(RotateDirection direction) { } } else if (direction == RotateDirection.COUNTERCLOCKWISE) { - CubeColor[] front_color = new CubeColor[3]; - for (int i = 0; i < 3; i++) { - front_color[i] = edges[4].getParts()[i][0]; - } for (int i = 0; i < 3; i++) { edges[4].getParts()[i][0] = edges[1].getParts()[i][0]; edges[1].getParts()[i][0] = edges[5].getParts()[2-i][2]; @@ -171,11 +173,13 @@ else if (direction == RotateDirection.COUNTERCLOCKWISE) { public void right(RotateDirection direction) { RotateItself(direction,3); + + CubeColor[] front_color = new CubeColor[3]; + for (int i = 0; i < 3; i++) { + front_color[i] = edges[4].getParts()[i][2]; + } + if (direction == RotateDirection.CLOCKWISE) { - CubeColor[] front_color = new CubeColor[3]; - for (int i = 0; i < 3; i++) { - front_color[i] = edges[4].getParts()[i][2]; - } for (int i = 0; i < 3; i++) { edges[4].getParts()[i][2] = edges[1].getParts()[i][2]; edges[1].getParts()[i][2] = edges[5].getParts()[2-i][0]; @@ -184,10 +188,6 @@ public void right(RotateDirection direction) { } } else if (direction == RotateDirection.COUNTERCLOCKWISE) { - CubeColor[] front_color = new CubeColor[3]; - for (int i = 0; i < 3; i++) { - front_color[i] = edges[4].getParts()[i][2]; - } for (int i = 0; i < 3; i++) { edges[4].getParts()[i][2] = edges[0].getParts()[i][2]; edges[0].getParts()[i][2] = edges[5].getParts()[2-i][0];