Exemplo n.º 1
0
 public void AddPlayer(Player player)
 {
     if (CheckIfPlayerExist(player))
     {
         throw new InvalidOperationException("Player already exist for this team");
     }
     this.players.Add(player);
 }
Exemplo n.º 2
0
Arquivo: Team.cs Projeto: 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");
 }
Exemplo 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);
        }
Exemplo n.º 5
0
 public bool CheckIfPlayerExist(Player player)
 {
     return this.players.Any(p => p.FirstName == player.FirstName && p.LastName == player.LastName);
 }
Exemplo n.º 6
0
Arquivo: Team.cs Projeto: Gab42/OOP
 private bool PlayerAddCheck(Player player)
 {
     return this.Players.Any(p => p.Firstname == player.Firstname && p.Lastname == player.Lastname);
 }
Exemplo n.º 7
0
 private bool CheckIfPlayerExists(Player player)
 {
     return this.players.Any(p => p.Name == player.Name &&
                                  p.Surname == player.Surname);
 }