private static void AddPlayerToTeam(string firstName, string lastName, DateTime dateOfBirth, decimal salary,
            string name)
        {
            Player player = new Player(firstName, lastName, salary, dateOfBirth);
            Team team = League.Teams.First(t => t.Name.Equals(name));

            if (!League.Teams.Contains(team))
            {
                League.AddTeam(team);
            }

            team.AddPlayer(player);
            Console.WriteLine("Successful added player {0} {1} to team {2}", firstName, lastName, name);
        }
Пример #2
0
 public void AddPlayer(Player player)
 {
     if (CheckPlayerExists(player))
     {
         throw new InvalidOperationException("Player already exists for that team");
     }
     this.players.Add(player);
     player.Team = this;
 }
Пример #3
0
 private bool CheckPlayerExists(Player player)
 {
     return this.players.Any(p => p.FirstName == player.FirstName &&
         p.LastName == player.LastName);
 }