我创建了这个构造函数来存储有关足球教练的信息。
String name;
Team team;
public Coach(String name, Team team){
this.name = name;
this.team = team;
}
然后使用用户输入的“名称”和“团队”创建教练对象
String name = nameField.getText();
Team team = (Team) teamComboBox.getSelectedItem();
// creates coach object
Coach coach = new Coach(name, team);
我的问题是,如何只允许为每个选定的团队创建1个教练对象?