Solved the error in the whatPiece
This commit is contained in:
parent
28b5df793b
commit
13d1dd4de5
|
|
@ -124,7 +124,7 @@ public class Board {
|
|||
public int whatPiece(int x, int y) { // method which gives the index (in the pieces array) of the piece at a position x,y
|
||||
boolean pieceHere = false;
|
||||
int index = 0;
|
||||
while (pieceHere == false) {
|
||||
while (pieceHere == false && index != pieces.size()) {
|
||||
if((x == pieces.get(index).getX()) && (y == pieces.get(index).getY())){
|
||||
pieceHere =true;
|
||||
}
|
||||
|
|
@ -132,6 +132,9 @@ public class Board {
|
|||
index += 1;
|
||||
}
|
||||
}
|
||||
if(index == pieces.size()) {
|
||||
index=-1;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue