Esempio n. 1
0
        static void Main()
        {
            ResultsTable pool1 = new ResultsTable();

            Team Wales = new Team("Wales");
            Team England = new Team("England");
            Team Australia = new Team("Australia");
            Team Fiji = new Team("Fiji");
            Team Uruguay = new Team("Uruguay");

            pool1.AddTeam(Wales);
            pool1.AddTeam(England);
            pool1.AddTeam(Australia);
            pool1.AddTeam(Fiji);
            pool1.AddTeam(Uruguay);

            Match walesEngland = new Match(Wales, England, 20, 15);
            Match walesFiji = new Match(Wales, Fiji, 80, 47);
            Match walesUruguay = new Match(Wales, Uruguay, 25, 10);
            Match walesAustralia = new Match(Wales, Australia, 12, 15);
            Match australiaEngland = new Match(Australia, England, 35, 15);
            Match australiaFiji = new Match(Australia, Fiji, 12, 0);
            Match australiaUruguay = new Match(Australia, Uruguay, 0, 15);
            Match englandFiji = new Match(England, Fiji, 18, 21);
            Match englandUruguay = new Match(England, Uruguay, 22, 10);
            Match fijiUruguay = new Match(Fiji, Uruguay, 4, 7);

            pool1.CalculateLeader();
            Console.WriteLine("The winner of pool 1 is {0}", pool1.Winner.Name);

            Console.WriteLine("{0} winner is {1}", walesAustralia.Name, walesAustralia.Winner.Name);
        }
Esempio n. 2
0
        public Match(Team team1, Team team2, int pointsTeam1, int pointsTeam2)
        {
            Name = team1.Name + " vs " + team2.Name;

            Team1 = team1;
            Team2 = team2;

            if (pointsTeam1 > pointsTeam2)
            {
                int numTries = pointsTeam1 % 7;

                Winner = Team1;

                if (numTries >= 4)
                {
                    Team1.Points += 5;
                }
                else
                {
                    Team1.Points += 4;
                }

                if (pointsTeam1 - pointsTeam2 <= 7)
                {
                    Team2.Points += 1;
                }
            }

            if (pointsTeam1 < pointsTeam2)
            {
                int numTries = pointsTeam2 % 7;

                Winner = Team2;

                if (numTries >= 4)
                {
                    Team2.Points += 5;
                }
                else
                {
                    Team2.Points += 4;
                }

                if (pointsTeam2 - pointsTeam1 <= 7)
                {
                    Team1.Points += 1;
                }
            }

            if (pointsTeam1 == pointsTeam2)
            {
                Winner = null;
                Team1.Points += 2;
                Team2.Points += 2;
            }
        }
Esempio n. 3
0
 public void CalculateLeader()
 {
     foreach (Team team in teams)
     {
         maxPoints = Math.Max(team.Points, maxPoints);
         if (maxPoints == team.Points)
         {
             Winner = team;
         }
     }
 }
Esempio n. 4
0
 public void AddTeam(Team TeamName)
 {
     teams.Add(TeamName);
 }