Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for(int i=0; i<(size); i++){
- for(int j=0; j<(size); j++){
- int actual = size*i+j;
- if((i == (size-1)) && (j == 0)){ // LU(0), U(1), RU(2), L(3), R(4), LD(5), D(6), RD(7)
- System.out.printf("[7,0]\n");
- this.boardArray[i][j].theNeighbourFields[Field.Direction.L.ordinal()] = this.boardArray[i][j-1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.U.ordinal()] = this.boardArray[i+1][j];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.LU.ordinal()] = this.boardArray[i+1][j-1];
- }else if( (i == (size-1)) && (j == (size-1)) ){
- System.out.printf("[7,7]\n");
- this.boardArray[i][j].theNeighbourFields[Field.Direction.L.ordinal()] = this.boardArray[i][j-1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.LD.ordinal()] = this.boardArray[i-1][j-1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.D.ordinal()] = this.boardArray[i-1][j];
- }else if( actual == 0 ){
- System.out.printf("[0,0]\n");
- this.boardArray[i][j].theNeighbourFields[Field.Direction.U.ordinal()] = this.boardArray[i][j+1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.RU.ordinal()] = this.boardArray[i+1][j+1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.R.ordinal()] = this.boardArray[i+1][j];
- }else if( actual == (size-1) ){
- System.out.printf("[0,7]\n");
- this.boardArray[i][j].theNeighbourFields[Field.Direction.RD.ordinal()] = this.boardArray[i+1][j-1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.D.ordinal()] = this.boardArray[i][j-1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.R.ordinal()] = this.boardArray[i+1][j];
- }else if(isBetween((size*(size-1)+1), ((size*size)-1), actual)){ //pravý sloupec 0,1,3,5,6
- System.out.printf("pravy slupec\n");
- this.boardArray[i][j].theNeighbourFields[Field.Direction.LU.ordinal()] = this.boardArray[i+1][j-1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.U.ordinal()] = this.boardArray[i+1][j];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.L.ordinal()] = this.boardArray[i][j-1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.LD.ordinal()] = this.boardArray[i-1][j-1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.D.ordinal()] = this.boardArray[i-1][j];
- //System.out.printf("Tu %d%d\n", this.boardArray[i][j].objColumn, this.boardArray[i][j].objRow);
- //System.out.printf("Tu %d%d\n", this.boardArray[i][j].theNeighbourFields[Field.Direction.L.ordinal()].objColumn, this.boardArray[i][j].theNeighbourFields[Field.Direction.L.ordinal()].objRow);
- }else if(isBetween(1, (size-2), actual)){ // levý sloupec
- System.out.printf("levy sloupec\n");
- this.boardArray[i][j].theNeighbourFields[Field.Direction.U.ordinal()] = this.boardArray[i+1][j];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.RU.ordinal()] = this.boardArray[i+1][j+1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.R.ordinal()] = this.boardArray[i][j+1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.D.ordinal()] = this.boardArray[i-1][j];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.RD.ordinal()] = this.boardArray[i-1][j+1];
- }else if( (actual % size) == (size-1) ){ // spodni řádek 1-6
- System.out.printf("spodni radek\n");
- this.boardArray[i][j].theNeighbourFields[Field.Direction.L.ordinal()] = this.boardArray[i][j-1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.R.ordinal()] = this.boardArray[i][j+1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.LD.ordinal()] = this.boardArray[i-1][j-1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.D.ordinal()] = this.boardArray[i-1][j];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.RD.ordinal()] = this.boardArray[i-1][j+1];
- }else if( (actual%size) == 0 ){ // horni řádek 57-63
- System.out.printf("horni radek\n");
- this.boardArray[i][j].theNeighbourFields[Field.Direction.LU.ordinal()] = this.boardArray[i+1][j-1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.U.ordinal()] = this.boardArray[i+1][j];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.RU.ordinal()] = this.boardArray[i+1][j+1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.L.ordinal()] = this.boardArray[i][j-1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.R.ordinal()] = this.boardArray[i][j+1];
- }else{ // zbytek, pole co nejsou na kraji
- System.out.printf("else\n");
- this.boardArray[i][j].theNeighbourFields[Field.Direction.LU.ordinal()] = this.boardArray[i+1][j-1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.U.ordinal()] = this.boardArray[i+1][j];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.RU.ordinal()] = this.boardArray[i+1][j+1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.L.ordinal()] = this.boardArray[i][j-1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.R.ordinal()] = this.boardArray[i][j+1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.LD.ordinal()] = this.boardArray[i-1][j-1];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.D.ordinal()] = this.boardArray[i-1][j];
- this.boardArray[i][j].theNeighbourFields[Field.Direction.RD.ordinal()] = this.boardArray[i-1][j+1];
- //System.out.printf("\nTu %d\n", this.boardArray[i][j].objColumn);
- //System.out.printf("Tu %d\n", this.boardArray[i][j].objRow);
- System.out.printf("Tu %d\n", this.boardArray[i][j].theNeighbourFields[Field.Direction.LD.ordinal()].objColumn);
- System.out.printf("Tu %d\n", this.boardArray[i][j].theNeighbourFields[Field.Direction.LD.ordinal()].objRow);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement