public TransferPlayerForm(Season season, Team originalTeam, Player player)
        {
            InitializeComponent();
            this.Season = season;
            this.OriginalTeam = originalTeam;
            this.Player = player;

            var teamSource = new Dictionary<int, string>();
            foreach (var team in this.Season.Teams)
            {
                teamSource.Add(this.Season.Teams.IndexOf(team), team.Name);
            }

            this.cmbBoxOriginalTeam.DataSource = new BindingSource(teamSource, null);
            this.cmbBoxNewTeam.DataSource = new BindingSource(teamSource, null);

            this.cmbBoxOriginalTeam.DisplayMember = "Value";
            this.cmbBoxNewTeam.DisplayMember = "Value";
            this.cmbBoxPlayer.DisplayMember = "Value";
        }
예제 #2
0
 public void AddPlayer(Player player)
 {
     foreach (Player teamPlayer in this.Players)
     {
         if (player.Number.Equals(teamPlayer.Number))
         {
             throw new Exception("New player cannot have the same number as another.");
         }
     }
     this.Players.Add(player);
 }
예제 #3
0
 public void RemovePlayer(Player player)
 {
     this.Players.Remove(player);
 }
예제 #4
0
 public void TransferPlayer(Player player, Team originalTeam, Team newTeam)
 {
     originalTeam.RemovePlayer(player);
     newTeam.AddPlayer(player);
     this.players[player] = newTeam;
 }
예제 #5
0
 public void CreatePlayer(String name, int number, Team team)
 {
     var player = new Player(name, number);
     team.AddPlayer(player);
     this.players.Add(player, team);
 }
예제 #6
0
 public void ChangePlayerNumber(Player player, int number)
 {
     player.ChangeNumber(number);
 }
예제 #7
0
 public void ChangePlayerName(Player player, String name)
 {
     player.ChangeName(name);
 }
예제 #8
0
 public void AddAwayGoalScorer(Player player, int goals)
 {
     if (!this.awayGoalScorers.ContainsKey(player))
     {
         this.awayGoalScorers.Add(player, goals);
         player.AddGoals(goals);
     }
     else
     {
         player.RemoveGoals(this.awayGoalScorers[player]);
         this.awayGoalScorers[player] = goals;
         player.AddGoals(goals);
     }
     var totalGoals = 0;
     foreach (var playerGoals in this.awayGoalScorers)
     {
         totalGoals += playerGoals.Value;
     }
     if (totalGoals > this.AwayTeamScore)
     {
         this.AwayTeamScore = totalGoals;
     }
 }