コード例 #1
0
ファイル: Program.cs プロジェクト: minde333/Savaranki-ki-U5
        static void Main(string[] args)
        {
            var p          = new Program();
            var AllPlayers = p.ReadPlayerData("NBA.csv", "FIFA.csv");
            var AllTeams   = p.ReadTeamData("TEAMS.csv");

            PlayerContainer filteredB = p.FilterPlayers(AllPlayers, AllTeams, "krepsininkas");
            PlayerContainer filteredF = p.FilterPlayers(AllPlayers, AllTeams, "footbolininkas");


            Console.WriteLine("Krepsinio zaidejai zaide visuose komandos zaidimuose ir yra rezultatyvus nemaziau kaip komandos vidurkis");
            Console.WriteLine();
            for (int i = 0; i < filteredB.Count; i++)
            {
                Console.WriteLine(filteredB.GetPlayer(i).ToString());
                Console.WriteLine($"Taskai : {filteredB.GetPlayer(i).GetPlayerScoreInfo()} , komandos vidurkis : {AllTeams.GetTeam(AllTeams.GetNameID(filteredB.GetPlayer(i).Team)).AverageScore} ");
                Console.WriteLine($"atkovoti Kamuoliai : {filteredB.GetPlayer(i).GetPlayerSpecialInfo()} , komandos vidurkis : {AllTeams.GetTeam(AllTeams.GetNameID(filteredB.GetPlayer(i).Team)).AverageSpecial} ");
                Console.WriteLine();
            }

            for (int i = 0; i < 1; i++)
            {
                Console.WriteLine();
            }

            Console.WriteLine("Futbolo zaidejai zaide visuose komandos zaidimuose ir yra rezultatyvus nemaziau kaip komandos vidurkis");
            Console.WriteLine();
            for (int i = 0; i < filteredF.Count; i++)
            {
                Console.WriteLine(filteredF.GetPlayer(i).ToString());
                Console.WriteLine($"Taskai : {filteredF.GetPlayer(i).GetPlayerScoreInfo()} , komandos vidurkis : {AllTeams.GetTeam(AllTeams.GetNameID(filteredF.GetPlayer(i).Team)).AverageScore} ");
                Console.WriteLine($"Geltonos korteles : {filteredF.GetPlayer(i).GetPlayerSpecialInfo()} , komandos vidurkis : {AllTeams.GetTeam(AllTeams.GetNameID(filteredF.GetPlayer(i).Team)).AverageSpecial} ");
                Console.WriteLine();
            }
            Console.WriteLine();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: minde333/Savaranki-ki-U5
        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);
        }