I\'m creating a rubiks and my results are this: I know the code seems long, but
ID: 3552583 • Letter: I
Question
I'm creating a rubiks and my results are this: I know the code seems long, but I really can't figure whats wrong. If you need my other files. I will surely e-mail them to you to look over. Top BlueBlueBlue BlueBlueBlue BlueBlueBlue Bottom (But i need this all Green) GreenBlackYellow BlackGreenBlack RedBlackBlack Front (All Red) BlackBlackBlack RedRedBlack BlackRedBlack Back (All Orange) OrangeBlackYellow OrangeOrangeOrange OrangeOrangeOrange Left WhiteWhiteWhite WhiteWhiteWhite WhiteWhiteWhite Right (All Yellow) BlackBlackBlack YellowYellowBlack YellowYellowBlack public class Rubiks extends Cube { public Rubiks() {MakeSolveCube(); } public static CubePos[][][] MakeSolveCube() { CubePos[][][]Pos = new CubePos[3][3][3]; // TODO Auto-generated method stub Pos[1][2][1] = new CubePos(new oneSide("R", CubeColor.Red) , CubeColor.Red); Pos[1][1][2] = new CubePos(new oneSide ( "B", CubeColor.Blue), CubeColor.Blue); Pos[2][1][1] = new CubePos(new oneSide ( "Y", CubeColor.Yellow), CubeColor.Yellow); Pos[1][0][1] = new CubePos(new oneSide ( "O", CubeColor.Orange), CubeColor.Orange); Pos[0][1][1] = new CubePos(new oneSide ( "W", CubeColor.White), CubeColor.White); Pos[1][1][0] = new CubePos(new oneSide ( "G", CubeColor.Green), CubeColor.Green); Pos[0][1][2] = new CubePos(new twoSide ( "BW", CubeColor.Blue, CubeColor.White) ,CubeColor.Blue); Pos[1][0][2] = new CubePos(new twoSide ("BO", CubeColor.Blue, CubeColor.Orange), CubeColor.Blue); Pos[2][1][2] = new CubePos(new twoSide ( "BY", CubeColor.Blue, CubeColor.Yellow) ,CubeColor.Blue); Pos[1][2][2] = new CubePos(new twoSide ( "BR", CubeColor.Blue, CubeColor.Red), CubeColor.Blue); Pos[1][0][0] = new CubePos(new twoSide ( "OG", CubeColor.Orange, CubeColor.Green), CubeColor.Orange); Pos[2][2][1] = new CubePos(new twoSide ( "YR", CubeColor.Yellow, CubeColor.Red), CubeColor.Yellow); Pos[2][0][1] = new CubePos(new twoSide ( "OY", CubeColor.Orange, CubeColor.Yellow), CubeColor.Orange); Pos[2][1][0] = new CubePos(new twoSide ( "YG", CubeColor.Yellow, CubeColor.Green), CubeColor.Yellow); Pos[0][2][1] = new CubePos(new twoSide ( "RW", CubeColor.Red, CubeColor.White), CubeColor.Red); Pos[0][0][1] = new CubePos(new twoSide ( "OW", CubeColor.Orange, CubeColor.White), CubeColor.Orange); Pos[1][2][0] = new CubePos(new twoSide ( "RG",CubeColor.Red, CubeColor.Green), CubeColor.Red); Pos[0][1][0] = new CubePos(new twoSide ( "WG", CubeColor.White, CubeColor.Green), CubeColor.White); Pos[0][0][0] = new CubePos(new threeSide ( "WGO",CubeColor.White, CubeColor.Green, CubeColor.Orange), CubeColor.White); Pos[2][0][0] = new CubePos(new threeSide ( "OGY", CubeColor.Orange, CubeColor.Green, CubeColor.Yellow), CubeColor.Orange); Pos[2][2][0] = new CubePos(new threeSide ( "YGR",CubeColor.Yellow, CubeColor.Green, CubeColor.Red) ,CubeColor.Yellow); Pos[0][2][0] = new CubePos(new threeSide ( "WRG", CubeColor.White, CubeColor.Red, CubeColor.Green), CubeColor.White); Pos[2][0][2] = new CubePos(new threeSide ( "BOY", CubeColor.Blue, CubeColor.Orange, CubeColor.Yellow), CubeColor.Blue); Pos[0][0][2] = new CubePos(new threeSide ( "BWO", CubeColor.Blue, CubeColor.White, CubeColor.Orange), CubeColor.Blue); Pos[0][2][2] = new CubePos(new threeSide ( "BRW", CubeColor.Blue, CubeColor.Red, CubeColor.White), CubeColor.Blue); Pos[2][2][2] = new CubePos(new threeSide ( "BYR", CubeColor.Blue, CubeColor.Yellow,CubeColor.Red),CubeColor.Blue); return Pos; } public static String PrettyDisplay(CubePos[][][] Pos) { String result =" Top "; for (int y =0;y<3; y++) { for (int x = 0; x<3; x++) { result += GetFacingColor(Pos[x][y][2],CubeColor.Blue, new Position(x,y,2))+ ""; } result += " "; } result +=" Bottom " ; for (int y =0;y<3; y++) { for (int x = 0; x<3; x++) { result += GetFacingColor(Pos[x][y][0],CubeColor.Green, new Position(x,y,0))+ ""; } result += " "; } result +=" Front " ; for (int z =2;z>=0; z--) { for (int x = 0; x<3; x++) { result += GetFacingColor(Pos[x][2][z],CubeColor.Red, new Position(x,2,z))+ ""; } result += " "; } result +=" Back " ; for (int z =2;z>=0;z--) { for (int x = 0; x<3; x++) { result += GetFacingColor(Pos[x][0][z],CubeColor.Orange, new Position(x,0,z))+ ""; } result += " "; } result +=" Left " ; for (int z =2;z>=0; z--) { for (int y = 0; y<3; y++) { result += GetFacingColor(Pos[0][y][0],CubeColor.White, new Position(0,y,z))+ ""; } result += " "; } result +="Right " ; for (int z =2;z>=0; z--) { for (int y = 2; y>=0; y--) { result += GetFacingColor(Pos[2][y][z],CubeColor.Yellow, new Position(2,y,z))+ ""; } result += " ";} return result;} public class CubePos { enum CubeColor{Red,Yellow, Green, White, Blue, Orange,Black} Cube Cube; CubeColor Primary; public CubePos(Cube cube, CubeColor primary2) { Cube = cube; Primary = primary2; } public CubePos() { Cube = null; Primary = null; } public String toString() { return Cube.Name; } public static CubeColor GetFacingColor(CubePos positionOfCube ,CubeColor side, Position pos) { if (positionOfCube.Cube instanceof oneSide) return GetFacingColor1( positionOfCube, side); if (positionOfCube.Cube instanceof twoSide) return GetFacingSide2(positionOfCube, side, pos); if (positionOfCube.Cube instanceof threeSide) return GetFaceingSide3(positionOfCube, side, pos); return CubeColor.Black; } public static CubeColor GetFacingColor1(CubePos positionOfCube, CubeColor side) { oneSide firstCube = (oneSide) positionOfCube.Cube; if (positionOfCube.Primary == side) return firstCube.Fir; return CubeColor.Black; } public static CubeColor GetFacingSide2(CubePos positionOfCube, CubeColor side, Position pos) { twoSide secondCube = (twoSide) positionOfCube.Cube; if (positionOfCube.Primary == side) return secondCube.Fir; CubeColor secondarySide = GetSecondaySide2(positionOfCube.Primary, pos); if (secondarySide == side) return secondCube.Sec; return CubeColor.Black; } public static CubeColor GetFaceingSide3(CubePos positionOfCube, CubeColor side, Position pos) { threeSide thirdCube = (threeSide) positionOfCube.Cube ; if (positionOfCube.Primary == side) return thirdCube.Fir; CubeColor secondarySide = GetSecondarySide3(positionOfCube.Primary, pos); if (secondarySide == side) return thirdCube.Sec; CubeColor ternarySide = GetTernarySide(positionOfCube.Primary , pos); if (ternarySide == side) return thirdCube.Third; return CubeColor.Black; } // TODO Auto-generated method stub public static CubeColor GetTernarySide(CubeColor primary2, Position pos) { // TODO Auto-generated method stub{ if (primary2 == CubeColor.Blue) { if (pos.x == 0&& pos.y == 0) return CubeColor.Orange; if (pos.x == 2 & pos.y == 0) return CubeColor.Yellow; if (pos.x == 0 && pos.y == 2) return CubeColor.White; if (pos.x == 2 && pos.y == 2) return CubeColor.Red; } if (primary2 == CubeColor.White) { if (pos.y == 0 && pos.z == 0) return CubeColor.Orange; if (pos.y == 2 && pos.z == 0) return CubeColor.Green; if (pos.y == 0 && pos.z == 2) return CubeColor.Blue; if (pos.y == 2 && pos.z == 2) return CubeColor.Red; } if (primary2 == CubeColor.Green) { if (pos.x == 0 && pos.y == 0) return CubeColor.Yellow; if (pos.x == 2 && pos.y == 0) return CubeColor.Orange; if (pos.x == 0 && pos.y == 2) return CubeColor.Red; if (pos.x == 2 && pos.y == 2) return CubeColor.White; } if (primary2 == CubeColor.Red) { if (pos.x == 2 && pos.z == 0) return CubeColor.Green; if (pos.x == 0 && pos.z == 0) return CubeColor.White; if (pos.x == 0 && pos.z == 2) return CubeColor.Blue; if (pos.x == 2 && pos.z == 2) return CubeColor.Yellow; } if (primary2 == CubeColor.Orange) { if (pos.x == 0 && pos.z == 2) return CubeColor.White; if (pos.x == 0 && pos.z == 0) return CubeColor.Green; if (pos.x == 2 && pos.z == 2) return CubeColor.Blue; if (pos.x == 2 && pos.z == 0) return CubeColor.Yellow; } if (primary2 == CubeColor.White) { if (pos.y == 0 && pos.z == 0) return CubeColor.Blue; if (pos.y == 2 && pos.z == 2) return CubeColor.Green; if (pos.y == 2 && pos.z == 0) return CubeColor.Orange; if (pos.y == 0 && pos.z == 2) return CubeColor.Red; } if (primary2 == CubeColor.Yellow) { if (pos.y == 0 && pos.z == 0) return CubeColor.Orange; if (pos.y == 2 && pos.z == 0) return CubeColor.Green; if (pos.y == 0 && pos.z == 2) return CubeColor.Blue; if (pos.y == 2 && pos.z == 2) return CubeColor.Red; } return CubeColor.Black; } public static CubeColor GetSecondarySide3(CubeColor primary2, Position pos) { // TODO Auto-generated method stub if (primary2== CubeColor.Blue) { if (pos.x == 0 && pos.y == 0) return CubeColor.White; if (pos.x == 2 && pos.y==0) return CubeColor.Orange; if (pos.x == 0 && pos.y == 2) return CubeColor.Red; if (pos.x == 2 && pos.y == 2) return CubeColor.Yellow; } if (primary2 == CubeColor.Green){ if (pos.x == 0 && pos.y == 0) return CubeColor.Orange; if (pos.x == 2 && pos.y == 0) return CubeColor.Yellow; if (pos.x == 0 && pos.y == 2) return CubeColor.White; if (pos.x == 2 && pos.y == 2) return CubeColor.Red; } if (primary2 == CubeColor.Red) { if (pos.x == 2 && pos.z == 0) return CubeColor.Yellow; if (pos.x == 2 && pos.z == 2) return CubeColor.Blue; if (pos.x == 0 && pos.z == 2) return CubeColor.White; if (pos.x == 0 && pos.z == 0) return CubeColor.Green; } if (primary2 == CubeColor.Orange) { if (pos.x == 0 && pos.z == 0) return CubeColor.White; if (pos.x == 2 && pos.z == 0) return CubeColor.Green; if (pos.x == 0 && pos.z == 2) return CubeColor.Blue; if (pos.x == 2 && pos.z == 2) return CubeColor.Yellow; } if (primary2 == CubeColor.White) { if (pos.y == 0 && pos.z == 0) return CubeColor.Green; if (pos.y == 2 && pos.z == 0) return CubeColor.Red; if (pos.y == 0 && pos.z == 2) return CubeColor.Orange; if (pos.y == 2 && pos.z == 2) return CubeColor.Blue; } if (primary2== CubeColor.Yellow) { if (pos.y == 0 && pos.z == 0) return CubeColor.Orange; if (pos.y == 2 && pos.z == 0) return CubeColor.Green; if (pos.y == 0 && pos.z == 2) return CubeColor.Blue; if (pos.y == 2 && pos.z == 2) return CubeColor.Red; } return CubeColor.Black; } public static CubeColor GetSecondaySide2(CubeColor primary2, Position pos) { if (primary2 == CubeColor.Blue || primary2 == CubeColor.Green) { if (pos.x == 0 && pos.y == 1) return CubeColor.Red; if (pos.x == 1 && pos.y == 0) return CubeColor.White; if (pos.x == 1 && pos.y == 2) return CubeColor.Yellow; if (pos.x == 2 && pos.y == 1) return CubeColor.Orange; } if (primary2 == CubeColor.White || primary2 == CubeColor.Yellow) { if (pos.y == 0 && pos.z == 1) return CubeColor.Orange; if (pos.x == 1 && pos.z == 2) return CubeColor.Blue; if (pos.y == 2 && pos.z == 1) return CubeColor.Red; if (pos.y == 1 && pos.z == 0) return CubeColor.Green; } if (primary2 == CubeColor.Orange || primary2 == CubeColor.Red) { if (pos.x == 0 && pos.z == 1) return CubeColor.White; if (pos.x == 2 && pos.z == 1) return CubeColor.Yellow; if (pos.x == 1 && pos.z == 2) return CubeColor.Blue; if (pos.x == 1 && pos.z == 0) return CubeColor.Green; } return CubeColor.Black; }}Explanation / Answer
http://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=video&cd=3&cad=rja&uact=8&ved=0CD8QtwIwAg&url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DYN97MjdHVd4&ei=I00pU7PXE9HKrAeAjYDQAg&usg=AFQjCNGAW0qjT7CbJnlW3c5xFYI_VhMyVg&sig2=ootG-AShS_QKARCIC4NV8g&bvm=bv.62922401,d.bmk
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.