Updated 'Node' class.

Updated the 'Node' class by overload the 'isOccupied' method in it.
This commit is contained in:
Daniel Grigencha
2024-12-03 04:57:30 +01:00
parent 0db1f08f3c
commit bb51976127

View File

@@ -49,4 +49,14 @@ public void clearOccupant() {
public boolean isOccupied() {
return occupant != null;
}
/**
* This method will be used to check if the node is occupied by a piece of the given color.
*
* @param color as the color of the piece as a Color object.
* @return true or false.
*/
public boolean isOccupied(Color color) {
return this.occupant != null && this.occupant.getColor() == color;
}
}