Ejemplo n.º 1
0
        PlayerContainer ReadPlayerData(string fileName1, string fileName2)
        {
            var    temp = new PlayerContainer(containerSize);
            string line;

            string[] lines;

            using (var reader = new StreamReader(fileName1))
            {
                while (null != (line = reader.ReadLine()))
                {
                    lines = line.Split(',');
                    var team       = lines[0];
                    var name       = lines[1];
                    var secondName = lines[2];
                    var date       = lines[3];
                    var ammount    = int.Parse(lines[4]);
                    var score      = int.Parse(lines[5]);
                    var getback    = int.Parse(lines[6]);
                    var assist     = int.Parse(lines[7]);
                    var temp2      = new BasketBall(score, getback, assist, team, name, secondName, date, ammount);
                    temp.AddPlayer(temp2);
                }
            }
            using (var reader = new StreamReader(fileName2))
            {
                while (null != (line = reader.ReadLine()))
                {
                    lines = line.Split(',');
                    var team       = lines[0];
                    var name       = lines[1];
                    var secondName = lines[2];
                    var date       = lines[3];
                    var ammount    = int.Parse(lines[4]);
                    var goal       = int.Parse(lines[5]);
                    var yellow     = int.Parse(lines[6]);
                    var temp2      = new FootBall(goal, yellow, team, name, secondName, date, ammount);
                    temp.AddPlayer(temp2);
                }
            }

            return(temp);
        }
Ejemplo n.º 2
0
        PlayerContainer FilterPlayers(PlayerContainer original, TeamContainer teams, string sport)
        {
            PlayerContainer Filtered = new PlayerContainer(containerSize);

            int    allScore     = 0;
            double averageScore = 0;

            int    allSpecial     = 0;
            double averageSpecial = 0;

            int members = 0;

            for (int i = 0; i < teams.Count; i++)
            {
                for (int j = 0; j < original.Count; j++)
                {
                    if (original.GetPlayer(j).Sport == sport)
                    {
                        if (teams.GetTeam(i).Name == original.GetPlayer(j).Team)
                        {
                            if (teams.GetTeam(i).Games == original.GetPlayer(j).Ammount)
                            {
                                allScore   += original.GetPlayer(j).GetPlayerScoreInfo();
                                allSpecial += original.GetPlayer(j).GetPlayerSpecialInfo();

                                members++;
                            }
                        }
                    }
                }

                if (members > 0)
                {
                    averageScore   = allScore / members;
                    averageSpecial = allSpecial / members;
                    teams.GetTeam(i).AverageScore   = averageScore;
                    teams.GetTeam(i).AverageSpecial = averageSpecial;
                }

                for (int j = 0; j < original.Count; j++)
                {
                    if (original.GetPlayer(j).Sport == sport)
                    {
                        if (teams.GetTeam(i).Name == original.GetPlayer(j).Team)
                        {
                            if (teams.GetTeam(i).Games == original.GetPlayer(j).Ammount)
                            {
                                if (original.GetPlayer(j).GetPlayerScoreInfo() >= averageScore)
                                {
                                    if (original.GetPlayer(j).GetPlayerSpecialInfo() >= averageSpecial)
                                    {
                                        Filtered.AddPlayer(original.GetPlayer(j));
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(Filtered);
        }