public void AddPlayer(Player player)
 {
     if (CheckIfPlayerExist(player))
     {
         throw new InvalidOperationException("Player already exist for this team");
     }
     this.players.Add(player);
 }
Esempio n. 2
0
File: Team.cs Progetto: Gab42/OOP
 public void AddPlayer(Player player)
 {
     if (PlayerAddCheck(player))
     {
         throw new InvalidOperationException("Player already exists in this team!");
     }
     this.players.Add(player);
     player.Team = this;
 }
 private static void AddPlayerToTeam(string firstName, string lastName, DateTime dateOfBirth, decimal salary, string team)
 {
     Team t = new Team(firstName, "       ", new DateTime(1850, 1, 1));
     t.Name = team;
     Player player = new Player(firstName, lastName, salary, dateOfBirth, t);
     if (t.CheckIfPlayerExist(player))
     {
         throw new InvalidOperationException("Player exist in this team");
     }
     t.AddPlayer(player);
     Console.WriteLine("Player - Confirmed");
 }
Esempio n. 4
0
        private static void AddPlayer(string firstName, string lastName, string dayB, string salaryStr, string teamName)
        {
            if (League.Teams.All(t => t.Name != teamName))
            {
                throw new InvalidOperationException("Team name");
            }

            var day = DateTime.Parse(dayB);
            var salary = decimal.Parse(salaryStr);
            var team = League.Teams.First(t => t.Name == teamName);
            var player = new Player(firstName, lastName, salary, day, team);
            team.AddPlayer(player);
        }
 public bool CheckIfPlayerExist(Player player)
 {
     return this.players.Any(p => p.FirstName == player.FirstName && p.LastName == player.LastName);
 }
Esempio n. 6
0
File: Team.cs Progetto: Gab42/OOP
 private bool PlayerAddCheck(Player player)
 {
     return this.Players.Any(p => p.Firstname == player.Firstname && p.Lastname == player.Lastname);
 }
Esempio n. 7
0
 private bool CheckIfPlayerExists(Player player)
 {
     return this.players.Any(p => p.Name == player.Name &&
                                  p.Surname == player.Surname);
 }