Exemplo n.º 1
0
 void ReadPlayersData(string fileName, PlayersContainer players)
 {
     using (StreamReader reader = new StreamReader(@fileName))
     {
         string line = null;
         if (fileName == "Krepšininkai.csv")
         {
             while (null != (line = reader.ReadLine()))
             {
                 string[]      values  = line.Split(',');
                 string        team    = values[0];
                 string        name    = values[1];
                 string        surname = values[2];
                 DateTime      birth   = DateTime.Parse(values[3]);
                 int           amountOfPlayedMatches = int.Parse(values[4]);
                 int           score              = int.Parse(values[5]);
                 int           rebounds           = int.Parse(values[6]);
                 int           effectiveTransfers = int.Parse(values[7]);
                 Basketballist basketballist      = new Basketballist(team, name, surname, birth, amountOfPlayedMatches, score, rebounds, effectiveTransfers);
                 players.AddPlayer(basketballist);
             }
         }
         else if (fileName == "Futbolininkai.csv")
         {
             while (null != (line = reader.ReadLine()))
             {
                 string[]    values  = line.Split(',');
                 string      team    = values[0];
                 string      name    = values[1];
                 string      surname = values[2];
                 DateTime    birth   = DateTime.Parse(values[3]);
                 int         amountOfPlayedMatches = int.Parse(values[4]);
                 int         score       = int.Parse(values[5]);
                 int         yellowCards = int.Parse(values[6]);
                 Footballist footballist = new Footballist(team, name, surname, birth, amountOfPlayedMatches, score, yellowCards);
                 players.AddPlayer(footballist);
             }
         }
     }
 }
Exemplo n.º 2
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);
        }