I let IntelliJ generate the override for and have tried to use equalsIgnoreCase but it doesn't seem to be working correctly, case is being ignored when adding the object to a Set.
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Player player = (Player) o;
//return playerName.equals(player.playerName);
return playerName.equalsIgnoreCase(player.playerName);
}
@Override
public int hashCode() {
return playerName.hashCode();
}
//Adds Players with the name of "bob" and "Bob" but don't want it to
boolean added = setOfPlayers.add(new Player(playerName.trim()));
if (!added) {
System.out.println("Player with the name " + playerName.trim() + " already exists");
}
Basically just want to have a set with Players that have unique names ignoring case.