Commit 0b662ace authored by amir's avatar amir

completing methods

parent a744669e
...@@ -45,6 +45,10 @@ public class Player { ...@@ -45,6 +45,10 @@ public class Player {
playerCoordinate[x][y]++; playerCoordinate[x][y]++;
} }
/**
* Checks if the match ends or not
* @return true if the match already ends and false if the match should be continued
*/
public boolean searchIfMatchEnds(){ public boolean searchIfMatchEnds(){
for (int i = 0; i < 6; i++){ for (int i = 0; i < 6; i++){
for (int j = 0; j < 6; j++){ for (int j = 0; j < 6; j++){
...@@ -57,6 +61,12 @@ public class Player { ...@@ -57,6 +61,12 @@ public class Player {
return false; return false;
} }
/**
*
* @param x
* @param y
* @return
*/
public boolean checkSides(int x, int y){ public boolean checkSides(int x, int y){
if (x != 0){ if (x != 0){
if (containsInArray(playerCoordinate, x - 1, y)){ if (containsInArray(playerCoordinate, x - 1, y)){
...@@ -105,6 +115,15 @@ public class Player { ...@@ -105,6 +115,15 @@ public class Player {
return false; return false;
} }
/**
* draws a line from x, y coordinate from a player's disc into
* specified direction to check if there is 5 in a line returns 5
* @param x the x of the coordinate
* @param y the y of the coordinate
* @param moveX the exact direct into x axis
* @param moveY the exact direct into y axis
* @return the number of discs of the player in a line
*/
public int countTheMoves(int x, int y, int moveX, int moveY){ public int countTheMoves(int x, int y, int moveX, int moveY){
int x1 = x + moveX; int x1 = x + moveX;
int y1 = y + moveY; int y1 = y + moveY;
...@@ -118,6 +137,11 @@ public class Player { ...@@ -118,6 +137,11 @@ public class Player {
return counter; return counter;
} }
/**
* displays the visualMap
* @param arr the coordinates of player1's discs
* @param arr2 the coordinates of player2's discs
*/
public void display(byte[][] arr, byte[][]arr2){ public void display(byte[][] arr, byte[][]arr2){
System.out.println(" 0 1 2 3 4 5"); System.out.println(" 0 1 2 3 4 5");
for (int i = 0; i < 3; i++){ for (int i = 0; i < 3; i++){
...@@ -164,6 +188,10 @@ public class Player { ...@@ -164,6 +188,10 @@ public class Player {
} }
} }
/**
* gets the coordinate domain of the board from the "searchCoordinate" method and rotates 90 degrees clockwise
* @param boardNumber the number of board to rotate
*/
public void rotate(byte boardNumber){ public void rotate(byte boardNumber){
byte[] bytes = new byte[2]; byte[] bytes = new byte[2];
bytes = searchCoordinate(boardNumber); bytes = searchCoordinate(boardNumber);
...@@ -184,6 +212,13 @@ public class Player { ...@@ -184,6 +212,13 @@ public class Player {
playerCoordinate[bytes[0]][bytes[1] + 1] = tmp2; playerCoordinate[bytes[0]][bytes[1] + 1] = tmp2;
} }
/**
* gets a board number and returns a byte array that the first
* index is the x of board's coordinate and the last
* index is the y of board's coordinate
* @param boardNumber number of board to search
* @return the byte array
*/
public byte[] searchCoordinate(byte boardNumber){ public byte[] searchCoordinate(byte boardNumber){
byte[] c = new byte[2]; byte[] c = new byte[2];
switch (boardNumber){ switch (boardNumber){
......
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