Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            TextPrinter textPrinter = new TextPrinter();

            textPrinter.PrintNextPage("Introduction");
            textPrinter.PrintNextPage("Contents");
            ImagePrinter imagePrinter = new ImagePrinter();

            imagePrinter.PrintNextPage(new byte[] { 40, 45, 6 });
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public void Cast()
        {
            PrinterBase printer = new TextPrinter();

            if (printer is TextPrinter)
            {
                ((TextPrinter)printer).PrintNextPage();
                TextPrinter textPrinter = (printer as TextPrinter);
                textPrinter.PrintNextPage();
            }

            if (!(printer is TextPrinterWithExtendedHeading))
            {
                ((TextPrinterWithExtendedHeading)printer).PrintNextPage();
                TextPrinter textPrinter = (printer as TextPrinterWithExtendedHeading);
                textPrinter.PrintNextPage();
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            TextPrinter textPrinter = new TextPrinter("Jungle book", new[] { "Introduction", "Contents" });

            textPrinter.PrintNextPage();
            textPrinter.PrintNextPage();
            ImagePrinter imagePrinter = new ImagePrinter("Jungle book", new byte[][] { new byte[] { 40, 45, 6 } });

            imagePrinter.PrintNextPage();
            TextPrinterWithExtendedHeading textPrinterWithExtendedHeading = new TextPrinterWithExtendedHeading("Jungle book", new[] { "Introduction", "Contents" });

            textPrinterWithExtendedHeading.PrintNextPage();
            //polymorphism
            PrinterBase printerA = new TextPrinter("Jungle book", new[] { "Introduction", "Contents" });
            PrinterBase printerB = new ImagePrinter("Jungle book", new byte[][] { new byte[] { 40, 45, 6 } });

            printerB.PrintNextPage();
            printerA.PrintNextPage();
            //
            Console.ReadLine();
        }