Beispiel #1
0
 private static void SaveGrades(GradeTracker book)
 {
     using (StreamWriter outputFile = File.CreateText("grades.txt"))
     {
         book.WriteGrades(outputFile);
     }
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            GradeTracker book = CreateGradeBook();

            book.AddGrades(new List <double>()
            {
                91, 90, 87.5
            });

            book.WriteGrades();

            GradeStatistics stats = book.ComputeStats();

            WriteResult("Average", stats.AverageGrade);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            GradeTracker book = CreateGradeBook();

            book.NameChanged += new NameChangedDelegate(OnNameChanged); // Add methods to delegate with +=
            book.NameChanged += OnNameChanged2;                         // Can also be written like this.
            //book.NameChanged = null;  NameChanged is an event.  Events can only add or subtract a subscriber.

            book.Name = null;
            book.Name = "Stephen's Grade Book";
            AddGrades(book);
            StreamWriter outputFile = File.CreateText("grades.txt");

            book.WriteGrades(outputFile);
            WriteResults(book);
        }