My program allows football coaches to be assigned to teams.
private String name;
private Team team;
public Coach(String name, Team team){
this.name = name;
this.team = team;
}
How do I check if a 'Coach'
object with a specific 'Team'
already exists. I want to stop two coaches from being assigned to the same Team.
String name = nameField.getText();
Team team = (Team) teamComboBox.getSelectedItem();
// I only want this to run, if the team doesn't already have a coach
Coach coach = new Coach(name, team);
I have spent hours reading similar questions but I haven't been able to get any of the code work. Any help would be appreciated, I'm pulling my hair out.