Пример #1
0
        //add players
        public void AddPlayer(Players player)
        {
            if (CheckIfPlayerExists(player))
               {
               throw new ArgumentException("Player with that name already exists for the current team");
               }

               this.players.Add(player);
        }
Пример #2
0
        private static void AddPlayerToTeam(string firstName, string lastName, DateTime birthDate,
            decimal salary, string teamAsString)
        {
            if (League.Teams.All(p => p.Name != teamAsString))
            {
                throw new ArgumentException("This team does not compete in the current League");
            }
            Teams newPLayerTeam = League.Teams.First(team => team.Name == teamAsString);
            Players newPlayer = new Players(firstName, lastName, birthDate, salary, newPLayerTeam);

            newPLayerTeam.AddPlayer(newPlayer);

            Console.WriteLine($"Player {newPlayer.FirstName} {newPlayer.LastName} added to team to" +
                              $" {newPLayerTeam.Name}");
        }
Пример #3
0
 private bool CheckIfPlayerExists(Players player)
 {
     return this.players.Any(p => p.FirstName == player.FirstName &&
                                 p.LastName == player.LastName);
 }