java - Temp 3d array not working -


i making program acts net of 2x2x2 rubik's cube. in method, plan make if statement each of 12 possible moves (up clockwise, counterclockwise, down clockwise, etc.), code turning clockwise not working. "move" string designated in main class , "cube" , "temp" both 3d char arrays containing current state of rubik's cube. "getturn" method rotates face clockwise , takes "cube" twice (once cube editing , once temp variable indeed work), int value of face being turned, , boolean value way being turned. working intended, when try create movement of sides of rubik's cube, temp variable "cube", called "temp" somehow altered code goes, creating incorrect outputs. believe there wrong way temp set up, because not behaving properly. thank helping me out!

public char[][][] getmove(char[][][] cube, char[][][] temp, string move) {      //0 = u     //1 = d     //2 = l     //3 = r     //4 = f     //5 = b      if(move.equals("u")) {         cube = getturn(cube, cube, 0, true);          cube[4][0][0] = temp[3][0][0]; cube[4][0][1] = temp[3][0][1];         cube[2][0][0] = temp[4][0][0]; cube[2][0][1] = temp[4][0][1];         cube[5][0][0] = temp[2][0][0]; cube[5][0][1] = temp[2][0][1];         cube[3][0][0] = temp[5][0][0]; cube[3][0][1] = temp[5][0][1]; 

edit:

i got working removing 3d array "temp" , replacing 8 temp ints:

public char[][][] getmove(char[][][] cube, string move) {      //0 = u     //1 = d     //2 = l     //3 = r     //4 = f     //5 = b      if(move.equals("u")) {         cube = getturn(cube, cube, 0, true);          char temp1 = cube[3][0][0];         char temp2 = cube[3][0][1];         char temp3 = cube[4][0][0];         char temp4 = cube[4][0][1];         char temp5 = cube[2][0][0];         char temp6 = cube[2][0][1];         char temp7 = cube[5][0][0];         char temp8 = cube[5][0][1];         cube[4][0][0] = temp1; cube[4][0][1] = temp2;         cube[2][0][0] = temp3; cube[2][0][1] = temp4;         cube[5][0][0] = temp5; cube[5][0][1] = temp6;         cube[3][0][0] = temp7; cube[3][0][1] = temp8; 

if knows why previous version not working, love know.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -