Commit e25994ec authored by amir's avatar amir

huge changes!!

parent 2bf341fa
package com.company;
public class Player {
private int[][] playerCoordinate;
public Player(){
playerCoordinate = new int[6][6];
}
public int[][] getPlayerCoordinate() {
return playerCoordinate;
}
public boolean containsInArray(int[][] arr, int x, int y){
if (arr[x][y] != 0)
return true;
else
return false;
}
public void addDisc(int[][] arr, int[][]arrOpponent, int x, int y){
if ((!containsInArray(arr, x, y)) && (!containsInArray(arrOpponent, x, y)))
arr[x][y]++;
}
public boolean searchIfMatchEnds(int[][] arr, int[][]arrOpponent){
for (int i = 0; i < 6; i++){
for (int j = 0; j < 6; j++){
if (containsInArray(arr, j, i)){
}
}
}
}
public void checkSides(int[][] arr,int x, int y){
if (x != 0){
if (containsInArray(arr, x - 1, y)){
if (checkTheMoveIfPossible(arrOpponent, arr, x, y, -1, 0))
}
if (y != 0){
if (containsInArray(arr, x - 1, y - 1))
if (checkTheMoveIfPossible(arrOpponent, arr, x, y, -1, -1))
return true;
}
if (y != 5){
if (containsInArray(arr, x - 1, y + 1))
if (checkTheMoveIfPossible(arrOpponent, arr, x, y, -1, +1))
return true;
}
}
if (x != 5){
if (containsInArray(arrOpponent, x + 1, y)){
if (checkTheMoveIfPossible(arrOpponent, arr, x, y, +1, 0))
return true;
}
if (y != 0){
if (containsInArray(arrOpponent, x + 1, y - 1))
if (checkTheMoveIfPossible(arrOpponent, arr, x, y, +1, -1))
return true;
}
if (y != 5){
if (containsInArray(arrOpponent, x + 1, y + 1)) {
if (checkTheMoveIfPossible(arrOpponent, arr, x, y, +1, +1))
return true;
}
}
}
if (y != 0){
if (containsInArray(arrOpponent, x, y - 1))
if (checkTheMoveIfPossible(arrOpponent, arr, x, y, 0, -1))
return true;
}
if (y != 5){
if (containsInArray(arrOpponent, x, y + 1)) {
if (checkTheMoveIfPossible(arrOpponent, arr, x, y, 0, +1))
return true;
}
}
return false;
}
}
package com.company;
public class Player1 extends Player {
}
package com.company;
public class Player2 extends Player {
}
...@@ -13,9 +13,35 @@ public class smallBoards { ...@@ -13,9 +13,35 @@ public class smallBoards {
if ((x >= 3) && (x < 6) && (y >= 0) && (y < 3)) if ((x >= 3) && (x < 6) && (y >= 0) && (y < 3))
return 2; return 2;
if ((x >= 0) && (x < 3) && (y >= 3) && (y < 6)) if ((x >= 0) && (x < 3) && (y >= 3) && (y < 6))
return 1; return 3;
if ((x >= 3) && (x < 6) && (y >= 3) && (y < 6)) if ((x >= 3) && (x < 6) && (y >= 3) && (y < 6))
return 4; return 4;
return 12; return 0;
}
public int rotate(int boardNumber){
int tmp = boardsCoordinate[2][0];
boardsCoordinate[2][0] = boardsCoordinate[0][0];
int tmp1 = boardsCoordinate[2][2];
boardsCoordinate[2][2] = tmp;
int tmp2 = boardsCoordinate[0][2];
boardsCoordinate[0][2] = tmp1;
boardsCoordinate[0][0] = tmp2;
int tmp3 = boardsCoordinate[1][0];
boardsCoordinate[1][0] = boardsCoordinate[0][1];
int tmp4 = boardsCoordinate[2][1];
boardsCoordinate[2][1] = tmp3;
int tmp5 = boardsCoordinate[1][2];
boardsCoordinate[1][2] = tmp4;
boardsCoordinate[0][1] = tmp5;
return boardNumber;
}
public void addDiscToTheBoard(int x, int y, int playerNumber){
if (boardsCoordinate[x][y] == 0)
boardsCoordinate[x][y] = playerNumber;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment