예제 #1
0
        static void Main(string[] args)
        {
            SpeechSynthesizer syn = new SpeechSynthesizer();

            syn.Speak("have a nice day");

            ThrowAwayGradeBook book = new ThrowAwayGradeBook();

            book.AddGrade(91);
            book.AddGrade(89.5f);
            book.AddGrade(75);
            book.NameChanged += onNameChanged;
            Console.WriteLine("Write your name");
            try
            {
                book.name = Console.ReadLine();
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }
            GradeStatistics stats = book.ComputeStatistics();

            WriteResult("Average", stats.average);
            WriteResult("Lowest", stats.lowest);
            WriteResult("Highest", stats.highest);
            Console.ReadLine();
        }
예제 #2
0
        static void Main(string[] args)
        {
            GradeBook book = new ThrowAwayGradeBook();

            book.NameChanged  = new NameChangedDelegates(OnNameChanged);
            book.NameChanged += new NameChangedDelegates(OnNameChanged2);
            book.AddGrade(96);
            book.AddGrade(89.6f);
            book.AddGrade(56.25f);
            book.Name = "Rahul's Book";
            book.Name = "Apple's Book";

            using (StreamWriter outputFile = File.CreateText("MyGradeBook.txt"))
            {
                book.WriteGrade(outputFile);
            }

            GradeStatistics stats = book.ComputeStatistics();

            Console.WriteLine(book.Name);
            WriteResult("Average", stats.AverageGrade);
            WriteResult("Lowest Grade", (int)stats.LowestGrade); // explicit
            WriteResult("Highest Grade", stats.HighestGrade, 1, 2, 6);
            WriteResult(stats.Description, stats.LetterGrade);
            Console.ReadKey();
        }
예제 #3
0
        static void Main(string[] args)
        {
            IGradeinterface bookOne = new ThrowAwayGradeBook();

            bookOne.AddGrade(10.8f);
            PrintStats(bookOne);

            GradeBook bookTwo = new GradeBook();

            AddGrade(bookTwo);

            Console.WriteLine(GradeAbstract.maxGrade);

            //System.Threading.Thread.Sleep(2000);
            PrintStats(bookTwo);

            /*SpeechSynthesizer sz = new SpeechSynthesizer();
            *  sz.Speak("Sum of the grades = " + gs.SumGrade);*/

            bookOne.AllocateParams(20, 30);
            SetGrade(bookOne, bookTwo);
            FileBookName(bookOne);

            Console.WriteLine("I am back running... :-)");

            foreach (float grd in bookOne)
            {
                Console.WriteLine(grd);
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            GradeBook book = new ThrowAwayGradeBook();

            // EnterName(book);
            AddGrades(book);
            SaveGrades(book);
            WriteResults(book);
        }
예제 #5
0
 static IGradeTracker InitializeGradeBook(string name)
 {
     var gradeBook = new ThrowAwayGradeBook();
     gradeBook.NameChanged += OnNameChanged;
     gradeBook.AddGrade(100f);
     gradeBook.AddGrade(80f);
     gradeBook.AddGrade(71f);
     gradeBook.AddGrade(92f);
     gradeBook.AddGrade(33f);
     gradeBook.Name = name;
     return gradeBook;
 }
예제 #6
0
        static void Main(string[] args)
        {
            GradeTracker book = new ThrowAwayGradeBook();

            book.NameChanged += OnNameChanged;

            try
            {
                book.Name = "Metin's new fantastic gradebook";
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }


            //book.NameChanged += new NameChangedDelegate(OnNameChanged);
            //book.NameChanged += new NameChangedDelegate(OnNameChanged2); //overrides onnamechanged if += is not used
            //now working with eventargs
            //book.NameChanged += OnNameChanged2; //overrides onnamechanged if += is not used
            //book.NameChanged -= OnNameChanged; removes 1 onNameChanged event from the list if exists any


            //book.NameChanged = null; // this assignment can only be made for delegates but can not be done for events. events accepts only subscribe or unscribe.
            //this is why events are preferred over delegated in order to provide protection

            //GetBookName(book);

            book.Name = "Metin's Gradebook";
            book.Name = "Metin's Gradebook2";

            AddGrades(book);

            //book.WriteGrades(Console.Out);
            //book.WriteGrades(); //overloaded
            SaveGrades(book);
            SpeechSynthesizer konus = new SpeechSynthesizer();

            //konus.Speak("writeresults removes lowest grade in throwawaygradebook.computestatistics so must be executed before writeresults");
            //konus.Speak("I have added a little wait here. no rush please. nereye gidiyon boyle a lahn");
            //WriteGradesInBytes(book); //writeresults removes lowest grade in throwawaygradebook.computestatistics so must be executed before writeresults


            WriteResults(book);

            //konus.Speak("writeresults removes lowest grade in throwawaygradebook.computestatistics so must be executed before writeresults");

            Console.ReadLine();
        }
예제 #7
0
        static void Main(string[] args)
        {
            //SpeechSynthesizer synth = new SpeechSynthesizer();
            //synth.Speak("Hello! This is the grade book program!");

            GradeBook book = new ThrowAwayGradeBook();

            //book.NameChanged += OnNameChanged;

            //try
            //{
            //    Console.WriteLine("Enter a name");
            //    book.Name = Console.ReadLine();
            //}
            //catch (ArgumentException ex)
            //{
            //    Console.WriteLine(ex.Message);
            //}
            //catch (NullReferenceException)
            //{
            //    Console.WriteLine("Something went wrong");
            //}
            book.AddGrade(91f);
            book.AddGrade(89.5f);
            //book.WriteGrade(Console.Out);
            //book.Name = "Scott's Grade Book";

            using (StreamWriter outputFile = File.CreateText("grades.txt"))
            {
                book.WriteGrade(outputFile);
            }

            GradeStatistics stats = book.ComputeStatistics();

            WriteResult("Average", stats.AverageGrade);
            WriteResult("Highest Grade", stats.HighestGrade);
            WriteResult("Lowest Gradde", stats.LowestGrade);
            //Console.WriteLine(book.Name);
            WriteResult(stats.Description, stats.LetterGrade);



            Console.ReadLine();

            //GradeBook g1 = new GradeBook();
            //GradeBook g2 = g1;
            //g1.Name = "Scott";
            //Console.WriteLine(g2.Name);
        }
예제 #8
0
        static void Main(string[] args)
        {
            //SpeechSynthesizer synth = new SpeechSynthesizer();
            //synth.Speak("Hello! This is the grade book program!");
            //book.NameChanged = OnNameChanged;
            //book.Name = "Scott's Grade Book";
            //Console.WriteLine(book.Name);

            GradeBook book = new ThrowAwayGradeBook();

            //GetBookName(book);
            AddGrades(book);
            SaveGrades(book);
            WriteResults(book);
        }
예제 #9
0
        static void Main()
        {
            GradeTracker book = new ThrowAwayGradeBook();

            book.NameChanged += OnNameChanged;

            PromptForGradebookName(book);
            EnterGrades(book);
            SaveGradesToFile(book);

            var stats = book.ComputeStatistics();

            foreach (var grade in book)
            {
                Console.WriteLine(grade);
            }

            WriteStatsToConsole(book, stats);
        }
예제 #10
0
        static void Main(string[] args)
        {
            //SpeechSynthesizer synth = new SpeechSynthesizer();
            //synth.Speak("hello");

            //GradeBook book =  new GradeBook();
            IGradeTracker book = new ThrowAwayGradeBook();

            book.NameChanged += new NameChangedDelegate(OnNameChanged); //use += to point delegates to many methods. / add subscription

            //    book.NameChanged += new NameChangedDelegate(OnNameChanged2);
            //    book.NameChanged -= new NameChangedDelegate(OnNameChanged2); //-= remove subscription

            // book.NameChanged = null; //this will point the delegate to null. removing subsriptions of all the above methods.
            //use events to prevent this.


            book.Name = "This is my book";
            book.Name = null; //this is not set because of the logic on the setter for Name.
            book.AddGrade(91);
            book.AddGrade(89.5f);

            foreach (float grade in book)
            {
                Console.WriteLine(grade);
            }

            Console.WriteLine(book.Name);

            GradeStatistics stats = book.ComputeStatistics();

            //Console.WriteLine(stats.HighestGrade);

            //    WriteResult("Avg grade is", stats.AverageGrade,2,3,4,5);
            WriteResult("Highest grade is", (int)stats.HighestGrade);
        }
 private static IGradeTracker CreateGradeBook()
 {
     IGradeTracker book = new ThrowAwayGradeBook("Scott's Book"); 
     return book;
 }
예제 #12
0
        private static IGradeTracker CraeteGradeBook()
        {
            IGradeTracker book = new ThrowAwayGradeBook("Aido knyga");

            return(book);
        }
예제 #13
0
파일: Program.cs 프로젝트: iimrankhan/PSSA
 private static IGradeTracker CreateGradeBook()
 {
     IGradeTracker book = new ThrowAwayGradeBook("Throw away gradebook");
     return book;
 }
예제 #14
0
 private static IGradeTracker CreateGradeBook()
 {
     IGradeTracker book = new ThrowAwayGradeBook("Peniel Tambama's Book");
     return book;
 }
예제 #15
0
        private static GradeBook CreateGradeBook()
        {
            GradeBook book = new ThrowAwayGradeBook("Sophie's Book");

            return(book);
        }
예제 #16
0
        static void Main(string[] args)
        {
            SpeechSynthesizer synth = new SpeechSynthesizer();

            synth.Speak("Hello! This is the grade book program");
            IGradeTracker book = new ThrowAwayGradeBook("Mina's Book");

            //book.AddGrade(91);
            //book.AddGrade(89.5f);
            //book.AddGrade(75); Do this instead:

            try
            {
                using (FileStream stream = File.Open("grades.txt", FileMode.Open))
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        string line = reader.ReadLine();
                        while (line != null)
                        {
                            float grade = float.Parse(line);
                            book.AddGrade(grade);
                            line = reader.ReadLine();
                        }
                    }

                //The next chunk is replaced by the code above. Just another way to do things
                //string[] lines = File.ReadAllLines("grades.txt");
                //foreach (string line in lines)
                //{
                //    float grade = float.Parse(line);
                //    book.AddGrade(grade);
                //}
                book.WriteGrades(Console.Out);
            }
            catch (FileNotFoundException ex)
            {
                Console.WriteLine("File not found!");
                return;
            }
            using (StreamWriter outputFile = File.CreateText("GradesResults.txt"))
            {
                book.WriteGrades(outputFile);
            }

            try
            {
                Console.WriteLine("Please enter a name for the book:");
                book.Name = Console.ReadLine();
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
                return;
            }


            WriteNames("Mina", "Mirna", "Magdi", "Manal");
            GradeStatistics stats = book.ComputeStatistics();

            stats.AvgGradeChange += new AvgGradechangedDelegate(OnAvgGradeChange);
            book.NameChanged     += new NamedChangedDelegate(OnNameChanged);

            int number = 20;

            WriteBytes(number);
            WriteBytes(stats.averageGrade);

            book.Name = "Amazing Book";

            WriteNames(book.Name);
            WriteResults(book);
            Console.WriteLine("{0} {1}", stats.LetterGrade, stats.Description); stats.LetterGrade = "A";
        }