public Match(SoccerTeam hometeam, SoccerTeam awayteam, int hometeamgoals, int awayteamgoals) { this.hometeam = hometeam; this.awayteam = awayteam; this.hometeamgoals = hometeamgoals; this.awayteamgoals = awayteamgoals; }
void Swap(int firstIndex, int secondIndex) { SoccerTeam temp = soccerTeams[firstIndex]; soccerTeams[firstIndex] = soccerTeams[secondIndex]; soccerTeams[secondIndex] = temp; }
public void Play(SoccerTeam hometeam, int hometeamgoals, SoccerTeam awayteam, int awayteamgoals) { Match match = new Match(hometeam, awayteam, hometeamgoals, awayteamgoals); match.UpdateRanking(); Sort(); }
public void AddNewTeam(SoccerTeam soccerTeam) { SoccerTeam[] temp = soccerTeams; Array.Resize(ref temp, soccerTeams.Length + 1); temp[soccerTeams.Length] = soccerTeam; soccerTeams = temp; Sort(); }
public int GetPositionForSoccerTeam(SoccerTeam soccerTeam) { for (int i = 0; i <= soccerTeams.Length - 1; i++) { if (soccerTeams[i] == soccerTeam) { return(i); } } return(-1); }
static void Swap(SoccerTeam[] teams, int firstIndex, int secondIndex) { (int minIndex, int maxIndex) = GetMinMaxIndex(firstIndex, secondIndex); const string message = "Swapping elements with indexes ({0}, {1}) and values ({2}, {3})"; Console.WriteLine(string.Format(message, minIndex, maxIndex, teams[minIndex].Name, teams[maxIndex].Name)); SoccerTeam temp = teams[minIndex]; teams[minIndex] = teams[maxIndex]; teams[maxIndex] = temp; }
static SoccerTeam[] ReadTeams() { SoccerTeam[] result = new SoccerTeam[14]; for (int i = 0; i < result.Length; i++) { string[] teamData = Console.ReadLine().Split('-'); int points = Convert.ToInt32(teamData[1]) + Convert.ToInt32(teamData[2]); result[i] = new SoccerTeam(teamData[0], points); } return(result); }
public bool LessPointsThan(SoccerTeam soccerTeam) { return(points < soccerTeam.points); }