コード例 #1
0
        static void Main(string[] args)
        {
            IBook book;

            System.Console.WriteLine("Enter a gradebook label, such \"[your_name]'s book\" or an example class like \"science\" or \"math\" ( this won't catch exceptions :) )");
            string bookLabel = Console.ReadLine();

            Console.WriteLine("Enter one of the following\n1: Save grades to file in src directory\n2: Save grades to memory only");
            string inputBookType = Console.ReadLine();

            switch (int.Parse(inputBookType))
            {
            case int d when d == 1:
                book = new DiscBook($"{bookLabel} grade book");
                break;

            default:
                book = new InMemoryBook($"{bookLabel} grade book");
                break;
            }
            book.GradeAdded += OnGradeAdded;

            System.Console.WriteLine(book.Name);


            EnterGrades(book);

            Statistics stats = book.GetStatistics();

            System.Console.WriteLine($"** {book.Name} Gradebook Statistics **");
            System.Console.WriteLine($"Average: {stats.Average}");
            System.Console.WriteLine($"Low: {stats.Low}");
            System.Console.WriteLine($"High: {stats.High}");
            System.Console.WriteLine($"Letter: {stats.Letter}");
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Stanmozolevskiy/GradeBook
        static void Main(string[] args)
        {
            var book = new DiscBook("My grade book");

            EnterGrade(book);

            var stats = book.GetStats();

            Console.WriteLine($"The Lowest grade is {stats.Low}");
            Console.WriteLine($"The Highest grade is {stats.High}");
            Console.WriteLine($"The Average grade is {stats.Average}");
            Console.WriteLine($"The Letter grade is {stats.Letter}");
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: carterjpilling/gradebook
        static void Main(string[] args)

        {
            IBook book = new DiscBook("Cj's Grade Book");

            //Handle event
            book.GradeAdded += OnGradeAdded;



            // book.GradeAdded = null; NOT ALLOWED
            EnterGrades(book);
            //Loop, enter new grade.

            var stats = book.GetStatistics();

            Console.WriteLine($"For the book named {book.Name}");
            Console.WriteLine($"The average grade is {stats.Average:N1}. The highest is {stats.High} and the lowest is {stats.Low}.");
            Console.WriteLine($"The letter grade is {stats.Letter}");
        }