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"; }
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); }
public void RemovePlayer(Player player) { this.Players.Remove(player); }
public void TransferPlayer(Player player, Team originalTeam, Team newTeam) { originalTeam.RemovePlayer(player); newTeam.AddPlayer(player); this.players[player] = newTeam; }
public void CreatePlayer(String name, int number, Team team) { var player = new Player(name, number); team.AddPlayer(player); this.players.Add(player, team); }
public void ChangePlayerNumber(Player player, int number) { player.ChangeNumber(number); }
public void ChangePlayerName(Player player, String name) { player.ChangeName(name); }
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; } }