-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRubiksSide.java
More file actions
78 lines (60 loc) · 1.79 KB
/
RubiksSide.java
File metadata and controls
78 lines (60 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package Rubix;
import javafx.scene.paint.Color;
public class RubixSide {
static final int SIZE = 3;
Color[][] values = new Color[SIZE][SIZE];
public RubixSide(Color color) {
for (int i = 0; i < SIZE; i++) {
for (int j = 0; j < SIZE; j++) {
values[i][j] = color;
}
}
}
public void reset(Color color) {
for (int i = 0; i < SIZE; i++) {
for (int j = 0; j < SIZE; j++) {
values[i][j] = color;
}
}
}
public void rotateSideCW(){
int m = values.length;
int n = values[0].length;
Color[][] newValues = new Color[m][n];
for (int i = 0; i < m; i++){
for (int j = 0; j < n; j++){
newValues[j][n - i - 1] = values[i][j];
}
}
values = newValues;
}
public void rotateSideCCW(){
int m = values.length;
int n = values[0].length;
Color[][] newValues = new Color[m][n];
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
newValues[n - j - 1][i] = values[i][j];
}
}
values = newValues;
}
public Color[] getRow(int row){
Color[] getRow = new Color[SIZE];
for (int i = 0; i < SIZE; i++){
getRow[i] = values[i][row];
}
return getRow;
}
public Color[] getCol(int col){
return values[col];
}
public void setRow(int row, Color[] newValues){
for (int i = 0; i < SIZE; i++){
values[i][row] = newValues[i];
}
}
public void setCol(int col, Color[] newValues){
values[col] = newValues;
}
}