예제 #1
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            Program           p          = new Program();
            BranchesContainer branches   = new BranchesContainer();
            PlayersContainer  football   = new PlayersContainer();
            PlayersContainer  basketball = new PlayersContainer();

            p.ReadBranchData(branches);
            p.ReadPlayersData("Krepšininkai.csv", basketball);
            p.ReadPlayersData("Futbolininkai.csv", football);
            p.BranchAdded(branches, basketball, football);

            string city;

            Console.WriteLine("Įveskite miestą:");
            city = Console.ReadLine();

            PlayersContainer filteredPlayers = new PlayersContainer();
            int Count = 0;


            Console.WriteLine("Krepšinio komandos ir jų žaidėjai:");
            for (int i = 0; i < branches.Count; i++)
            {
                filteredPlayers = p.FilteredBasketballists(branches, city);

                if (filteredPlayers.Count > 0)
                {
                    p.PrintPlayersToConsole(filteredPlayers);
                    Count++;
                }
            }
            if (Count == 0)
            {
                Console.WriteLine("Tokiame mieste krepšinio komandų nėra");
            }
            Count = 0;
            Console.WriteLine("Futbolo komandos ir jų žaidėjai:");
            Console.WriteLine("");
            for (int i = 0; i < branches.Count; i++)
            {
                filteredPlayers = p.FilteredFootballists(branches, city);
                if (filteredPlayers.Count > 0)
                {
                    p.PrintPlayersToConsole(filteredPlayers);
                    Count++;
                }
            }
            if (Count == 0)
            {
                Console.WriteLine("Tokiame mieste futbolo komandų nėra");
            }
        }
예제 #2
0
 void ReadBranchData(BranchesContainer branches)
 {
     using (StreamReader reader = new StreamReader(@"komandos.csv"))
     {
         string line = null;
         while (null != (line = reader.ReadLine()))
         {
             string[] values  = line.Split(',');
             string   team    = values[0];
             string   city    = values[1];
             string   coach   = values[2];
             int      matches = int.Parse(values[3]);
             Branch   branch  = new Branch(team, city, coach, matches);
             branches.AddBranch(branch);
         }
     }
 }
예제 #3
0
        void BranchAdded(BranchesContainer branches, PlayersContainer basketball, PlayersContainer football)
        {
            for (int i = 0; i < branches.Count; i++)
            {
                for (int g = 0; g < basketball.Count; g++)
                {
                    if (branches.GetBranch(i).Team == basketball.GetPlayer(g).Team)
                    {
                        branches.branches[i].Basketballists.AddPlayer(basketball.GetPlayer(g));
                    }
                }

                for (int g = 0; g < football.Count; g++)
                {
                    if (branches.GetBranch(i).Team == football.GetPlayer(g).Team)
                    {
                        branches.branches[i].Footballists.AddPlayer(football.GetPlayer(g));
                    }
                }
            }
        }
예제 #4
0
        PlayersContainer FilteredFootballists(BranchesContainer branches, string city)
        {
            PlayersContainer filteredFootbaliists = new PlayersContainer();

            for (int i = 0; i < branches.Count; i++)
            {
                if (branches.GetBranch(i).City == city && branches.GetBranch(i).Footballists.Count > 0)
                {
                    for (int g = 0; g < branches.GetBranch(i).Footballists.Count; g++)
                    {
                        if (branches.GetBranch(i).Footballists.GetPlayer(g).Score >= branches.GetBranch(i).Footballists.Average() &&
                            branches.GetBranch(i).Footballists.GetPlayer(g).AmountOfPlayedMatches == branches.GetBranch(i).AmountOfPlayedMatches)
                        {
                            filteredFootbaliists.AddPlayer(branches.GetBranch(i).Footballists.GetPlayer(g));
                        }
                    }
                    branches.GetBranch(i).City = "";
                    break;
                }
            }
            return(filteredFootbaliists);
        }