Exemple #1
0
        static void Main(string[] args)
        {
            GradeAddedDelegate logger = (object sender, EventArgs eventArguments) => {
                Console.WriteLine($"GradeAdded: {sender.ToString()}");
            };

            var demo = new Book("Demo");

            demo.GradeAdded += logger;
            demo.GradeAdded += GradesCounter;

            demo.AddGrade(95);
            demo.AddGrade(50);
            demo.AddGrade(90);
            demo.AddGrade(100);
            demo.AddGrade(83.3);


            Console.WriteLine($"Grades Added: {counter}.");
            Console.WriteLine(demo.ToString());
            Console.WriteLine(demo.GetStatistics().ToString());
        }
Exemple #2
0
 public Book(string name, GradeAddedDelegate gradeAdded) : base(name)
 {
     statistics = new Statistics(gradeAdded);
 }
Exemple #3
0
 public Statistics(GradeAddedDelegate gradeAddedDelegate)
 {
     this.gradeAddedDelegate = gradeAddedDelegate;
     gradeAddedDelegate     += OnGradeAdded;
 }