Esempio n. 1
0
 public Match(SoccerTeam hometeam, SoccerTeam awayteam, int hometeamgoals, int awayteamgoals)
 {
     this.hometeam      = hometeam;
     this.awayteam      = awayteam;
     this.hometeamgoals = hometeamgoals;
     this.awayteamgoals = awayteamgoals;
 }
Esempio n. 2
0
        void Swap(int firstIndex, int secondIndex)
        {
            SoccerTeam temp = soccerTeams[firstIndex];

            soccerTeams[firstIndex]  = soccerTeams[secondIndex];
            soccerTeams[secondIndex] = temp;
        }
Esempio n. 3
0
        public void Play(SoccerTeam hometeam, int hometeamgoals, SoccerTeam awayteam, int awayteamgoals)
        {
            Match match = new Match(hometeam, awayteam, hometeamgoals, awayteamgoals);

            match.UpdateRanking();
            Sort();
        }
Esempio n. 4
0
 public void AddNewTeam(SoccerTeam soccerTeam)
 {
     SoccerTeam[] temp = soccerTeams;
     Array.Resize(ref temp, soccerTeams.Length + 1);
     temp[soccerTeams.Length] = soccerTeam;
     soccerTeams = temp;
     Sort();
 }
Esempio n. 5
0
 public int GetPositionForSoccerTeam(SoccerTeam soccerTeam)
 {
     for (int i = 0; i <= soccerTeams.Length - 1; i++)
     {
         if (soccerTeams[i] == soccerTeam)
         {
             return(i);
         }
     }
     return(-1);
 }
Esempio n. 6
0
        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;
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
 public bool LessPointsThan(SoccerTeam soccerTeam)
 {
     return(points < soccerTeam.points);
 }