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