Exemple #1
0
        private List <NFLPlayer> GetPlayerList(string filePath)
        {
            List <NFLPlayer> playerList = new List <NFLPlayer>();

            try
            {
                using (StreamReader reader = new StreamReader(filePath))
                {
                    string line;

                    while ((line = reader.ReadLine()) != null)
                    {
                        string[] data = line.Split(',');
                        double   fumbles;

                        Yards yards = GetPlayersYards(data);        //Creates a Yards instance for each player
                        TDS   tds   = GetPlayersTDs(data);          //Creates a Touch Down instance for each player

                        if (Double.TryParse(data[12], out fumbles)) //parses fumbles to a double, if that happens then the player is added
                        {
                            playerList.Add(new NFLPlayer(data[0], data[1], data[2], data[3],
                                                         yards, tds, fumbles));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("File not found.");
            }


            return(playerList);
        }
Exemple #2
0
 public NFLPlayer(string n, string p, string t, string b, Yards y, TDS td, double f)
     : base(n, p, t)
 {
     Bye        = b;
     Yardage    = y;
     TouchDowns = td;
     Fumbles    = f;
 }