Modifier and Type | Field and Description |
---|---|
private int |
numberOfDisks |
private int |
possibleMoves |
Constructor and Description |
---|
Players()
Creates a player and initials the possible moves with zero
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkSides(int[][] arrOpponent,
int[][] arr,
int x,
int y)
checks the sides of the blank to see if there is an opponent disk or not
and then goes to the "checkTheMoveIfPossible" method
|
boolean |
checkTheMoveIfPossible(int[][] arrOpponent,
int[][] arr,
int x,
int y,
int moveX,
int moveY)
checks the move if possible :))
|
boolean |
containsInArray(int[][] arr,
int x,
int y)
gets an array(player1 or player2) and a coordinate and checks
if the coordinate contains in the array
|
void |
display(int[][] a1,
int[][] a2)
displays the place of black and white discs and blanks (will be overridden in console and graphic version)
|
void |
equalize(int[][] arrOpponent,
int[][] arr,
int x,
int y,
int moveX,
int moveY)
this method checks if the move is possible, then equalize the color of the
player's disc in a line from the blank to the first player's disk that seen
|
int |
getNumberOfDisks(int[][] arr)
gets a player's array and returns the number of it's discs
|
int |
numberOfPlayerPossibleMoves(int[][] arrOpponent,
int[][] arr)
this method returns the number of possible moves by finding blanks and
checking sides that if there is a possible move
|
void |
searchInNeighbors(int[][] arrOpponent,
int[][] arr,
int x,
int y)
this method gets the coordinate of a blank space an checks if there is
a opponent disc,and then if exists for each of opponent disks does the equalize method
|
public Players()
public boolean containsInArray(int[][] arr, int x, int y)
arr
- the array to check it's valuesx
- the x of the coordinatey
- the y of the coordinatepublic void display(int[][] a1, int[][] a2)
a1
- array of the player1's discsa2
- array of the player2's discspublic void searchInNeighbors(int[][] arrOpponent, int[][] arr, int x, int y)
arrOpponent
- list of opponent discs' coordinatesarr
- list of the player disc's coordinatesx
- the x of the blank spacey
- the y of the blank spacepublic void equalize(int[][] arrOpponent, int[][] arr, int x, int y, int moveX, int moveY)
arrOpponent
- list of opponent discs' coordinatesarr
- list of the player disc's coordinatesx
- the x of the blank spacey
- the y of the blank spacemoveX
- the direction to the x esmoveY
- the direction to the y espublic int numberOfPlayerPossibleMoves(int[][] arrOpponent, int[][] arr)
arrOpponent
- the coordinates of opponent player's discsarr
- the coordinates of the player's discspublic boolean checkSides(int[][] arrOpponent, int[][] arr, int x, int y)
arrOpponent
- the coordinates of opponent's discsarr
- the coordinates of player's discsx
- the x coordinate of blanky
- the x coordinate of blankpublic boolean checkTheMoveIfPossible(int[][] arrOpponent, int[][] arr, int x, int y, int moveX, int moveY)
arrOpponent
- the coordinates of opponent's discsarr
- the coordinates of player's discsx
- the x coordinate of blanky
- the x coordinate of blankmoveX
- the direction in the x axis (0, 1 or -1)moveY
- the direction in the x axis (0, 1 or -1)public int getNumberOfDisks(int[][] arr)
arr
- player1(2)'s array