Updated 'Game' class.

Updated the 'Game' class by adding the 'isColorTaken' method to it.
This commit is contained in:
Daniel Grigencha
2024-12-02 18:18:04 +01:00
parent f21fd9b0a6
commit 09fda6b167

View File

@@ -96,6 +96,23 @@ public void updatePlayerActiveState(int id, boolean active) {
this.players.get(id).setActive(active);
}
/**
* This method will be used to check if the given color parameter is already taken.
* If yes it will return true, otherwise false.
*
* @param color as the color which should be checked if taken as a Color enumeration.
* @return true or false.
*/
public boolean isColorTaken(Color color) {
for (Map.Entry<Integer, Player> entry : this.players.entrySet()) {
if (entry.getValue().getColor() == color) {
return true;
}
}
return false;
}
/**
* This method will be used to return the player which has the given id parameter.
*