Exemplo n.º 1
0
        static void LoadFile(string fullPath)
        {
            ScoreSheet sheet = new ScoreSheet(sheet_Message);
            string     data  = string.Empty;


            if (File.Exists(fullPath))
            {
                using (StreamReader reader = new StreamReader(fullPath))
                {
                    data = reader.ReadToEnd();
                    reader.Close();
                }
                bool          IsValid = false;
                List <string> lines   = sheet.Process(data, ref IsValid);

                if (IsValid)
                {
                    TeamResults results = sheet.SmallestForAgainstGoal(lines);
                    Console.WriteLine("----------");
                    Console.Write("Team with smallest For and Against goal(s) is : {0} with difference of {1} goal(s)\n", results.Name, results.ForAgainstDifference.ToString());
                }
            }
            else
            {
                Console.WriteLine("File does not exists.");
            }
        }
Exemplo n.º 2
0
        public TeamResults SmallestForAgainstGoal(List <string> data)
        {
            TeamResults teamResults = new TeamResults();

            string[] columns;
            string   team;
            int      F;
            int      A;
            int      diff;

            for (int i = 0; i < data.Count; i++)
            {
                columns = data[i].Split(',');
                team    = columns[_columnLocation[0]];
                F       = int.Parse(columns[_columnLocation[5]]);
                A       = int.Parse(columns[_columnLocation[6]]);
                diff    = F > A ? F - A : A - F;

                if (diff < teamResults.ForAgainstDifference)
                {
                    teamResults.Name = team;
                    teamResults.ForAgainstDifference = diff;
                }
            }

            return(teamResults);
        }