示例#1
0
文件: Team.cs 项目: sashkooooy/MyRepo
        public void AddPlayer(Players player)
        {
            if (CheckIfPlayerExists(player))
            {
                throw new InvalidOperationException("The player already exists.");
            }

            else
            {
                this.players.Add(player);
            }
        }
示例#2
0
文件: Team.cs 项目: sashkooooy/MyRepo
 public bool CheckIfPlayerExists(Players player)
 {
     return this.players.Any(p => p.FirstName == player.FirstName && p.LastName == p.LastName);
 }