예제 #1
0
        public static void complexAbstractDemo()
        {
            System.Console.WriteLine("\n### complexAbstractDemo");

            AbstractItem[] items = new AbstractItem[5];
            items[0] = new VHS("StarWars", 130, 5043, VHSType.Size300);
            items[1] = new DVD("LoTR", 200, 20000, DVDType.LayerTwo);
            items[2] = new VHS("Matrix", 400, 432, VHSType.Size240);
            items[3] = new DVD("Bloff", 65, 55043, DVDType.LayerTwo);
            items[4] = new DVD("StarTrek", 2400, 20, DVDType.LayerOne);

            for (int i = 0; i < items.Length; i++)
            {
                System.Console.WriteLine(items[i].play());
            }
        }
예제 #2
0
        public static void abstractDemo()
        {
            System.Console.WriteLine("\n### (1) AbstractItem iItem = new AbstractItem()");
            // AbstractItem iItem = new AbstractItem("AlmaItem", 10, 1000);
            System.Console.WriteLine("n/a");

            // ugyanaz a hatasa, mint a Virtual metodus hivas eseten. Ugyanugy VMT epul
            System.Console.WriteLine("\n### (2) DVD iDVD = new DVD()");
            DVD iDVD = new DVD("AlmaDVD", 20, 500.0, DVDType.LayerOne);
            System.Console.WriteLine(iDVD.play()); // Play VDVD --> DVD
            System.Console.WriteLine(iDVD.handle()); // Play VDVD --> DVD

            // ugyanaz a hatasa, mint a Virtual metodus hivas eseten. Ugyanugy VMT epul
            System.Console.WriteLine("\n### (3) AbstractItem iItemDVD = new DVD()");
            AbstractItem iItemDVD = new DVD("AlmaDVD", 20, 500.0, DVDType.LayerOne);
            System.Console.WriteLine(iItemDVD.play()); // Play VDVD
            System.Console.WriteLine(iItemDVD.handle()); // Play VDVD

            System.Console.WriteLine("\n### (4) DVD iDVD = new DVD() --> AbstractItem");
            Program.abstractPrint(iDVD);
            // ezek utan ez is egyertelmu, hogy minden a DVD osztalyban fut
        }