Beispiel #1
0
        // Execution starts here.
        static void Main()
        {
            BookDB bookDB = new BookDB();

            // Initialize the database with some books:
            AddBooks(bookDB);

            // Print all the titles of paperbacks:
            System.Console.WriteLine("Paperback Book Titles:");

            // Create a new delegate object associated with the static 
            // method Test.PrintTitle:
            bookDB.ProcessPaperbackBooks(PrintTitle);

            // Get the average price of a paperback by using
            // a PriceTotaller object:
            PriceTotaller totaller = new PriceTotaller();

            // Create a new delegate object associated with the nonstatic 
            // method AddBookToTotal on the object totaller:
            bookDB.ProcessPaperbackBooks(totaller.AddBookToTotal);

            System.Console.WriteLine("Average Paperback Book Price: ${0:#.##}",
                    totaller.AveragePrice());

            Console.ReadLine();
        }
Beispiel #2
0
 static void AddBooks(BookDB bookDB)
 {
     bookDB.AddBook("The C Programming Language", "Brian W. Kernighan and Dennis M. Ritchie", 19.95m, true);
     bookDB.AddBook("The Unicode Standard 2.0", "The Unicode Consortium", 39.95m, true);
     bookDB.AddBook("The MS-DOS Encyclopedia", "Ray Duncan", 129.95m, false);
     bookDB.AddBook("Dogbert's Clues for the Clueless", "Scott Adams", 12.00m, true);
 }
Beispiel #3
0
 // Initialize the book database with some test books:
 static void AddBooks(BookDB bookDB)
 {
     bookDB.AddBook("The C Programming Language", "Brian W. Kernighan and Dennis M. Ritchie", 19.95m, true);
     bookDB.AddBook("The Unicode Standard 2.0", "The Unicode Consortium", 39.95m, true);
     bookDB.AddBook("The MS-DOS Encyclopedia", "Ray Duncan", 129.95m, false);
     bookDB.AddBook("Dogbert's Clues for the Clueless", "Scott Adams", 12.00m, true);
     bookDB.AddBook("Learning to Indent Your F*****g Code", "The BoogyMan", 12.00m, true);
 }
Beispiel #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Available Books : ");
            var bookdb = new BookDB();

            bookdb.AddBook("Jungle Book", 6.5m, true);
            bookdb.AddBook("Soft Computing", 99.99m, false);
            bookdb.AddBook("The Greate Escape", 8.9m, true);
            bookdb.AddBook("World War II", 55.2m, true);


            bookdb.ProcessPaperbackBook(PrintTitle);
            Console.ReadKey();
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            BookDB bookDB = new BookDB();

            AddBooks(bookDB);
            PriceTotaller totaller = new PriceTotaller();

            bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(PrintTitle));

            bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(totaller.AddBookToTotal));
            Console.WriteLine("Average Paperback Book Price: ${0:#.##}", totaller.AveragePrice());

            Console.ReadLine();

            //Output
            //Paperback Book Titles:
            //The C Programming Language
            //The Unicode Standard 2.0
            //Dogbert's Clues for the Clueless
            //Average Paperback Book Price: $23.97
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            BookDB bookDB = new BookDB();
            AddBooks(bookDB);
            PriceTotaller totaller = new PriceTotaller();

            bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(PrintTitle));

            bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(totaller.AddBookToTotal));
            Console.WriteLine("Average Paperback Book Price: ${0:#.##}", totaller.AveragePrice());

            Console.ReadLine();

            //Output
            //Paperback Book Titles:
            //The C Programming Language
            //The Unicode Standard 2.0
            //Dogbert's Clues for the Clueless
            //Average Paperback Book Price: $23.97
        }