public static void GreatestPointDiff(List <SuperBowlWinner> SuperBowlWinners, StreamWriter Writer) { //getting the game with the highest point difference between the two teams. int MaxPointDiff = 0; SuperBowlWinner MaxDiff = SuperBowlWinners[1]; foreach (var i in SuperBowlWinners) { if (i.PointDiff > MaxPointDiff) { MaxPointDiff = i.PointDiff; MaxDiff = i; } } Writer.WriteLine("The game with the greatest point difference was Super Bowl #: {0} \n with the {1} beating the {2} {3} to {4}", MaxDiff.SBNumber, MaxDiff.WinningTeam, MaxDiff.LosingTeam, MaxDiff.WinningPoints, MaxDiff.LosingPoints); }
public static List <SuperBowlWinner> ReadFile() { //Declarations List <SuperBowlWinner> SuperBowlWinners = new List <SuperBowlWinner>(); SuperBowlWinner ASuperbowlwinner; string FilePath = Directory.GetParent(Directory.GetParent(Environment.CurrentDirectory).ToString()).ToString() + @"\Super_Bowl_Project.csv"; string[] Values; // attempting to open the file and put data into the class list try { FileStream file = new FileStream(FilePath, FileMode.Open, FileAccess.Read); StreamReader Reader = new StreamReader(file); while (!Reader.EndOfStream) { Values = Reader.ReadLine().Split(','); if (Values[0] != "Date") { ASuperbowlwinner = new SuperBowlWinner(Values[0], Values[1], Convert.ToInt32(Values[2]), Values[3], Values[4], Values[5], Convert.ToInt32(Values[6]), Values[7], Values[8], Values[9], Convert.ToInt32(Values[10]), Values[11], Values[12], Values[13], Values[14], Convert.ToInt32(Values[6]) - Convert.ToInt32(Values[10])); SuperBowlWinners.Add(ASuperbowlwinner); } } file.Close(); Reader.Close(); } // Will print out the exception catch (Exception i) { Console.WriteLine(i); Console.WriteLine("Press any key to continue"); Console.ReadKey(); } // Returns the list return(SuperBowlWinners); }