Esempio n. 1
0
        static void Main(string[] args)
        {
            Journal  journal0  = new Journal("Journal0", 100, "BindingJ", "AuthorJ", "Publishing HouseJ");
            Textbook textbook0 = new Textbook("Textbook0", 200, "BindingT", "AuthorT", "Publishing HouseT");
            Book     book0     = new Book("Book0", 300, "BindingB", "AuthorB", "Publishing HouseB");
            Journal  journal1  = new Journal("Journal1", 400, "BindingJ", "AuthorJ", "Publishing HouseJ");
            Textbook textbook1 = new Textbook("Textbook1", 500, "BindingT", "AuthorT", "Publishing HouseT");
            Book     book1     = new Book("Book1", 600, "BindingB", "AuthorB", "Publishing HouseB");

            Console.WriteLine(journal0.ToString());

            book1.preview();
            book1.inspect();
            ((IAction)book1).inspect();
            book1.read();

            Boolean test = book0 is Book;

            Console.WriteLine(test);
            Console.WriteLine(textbook0 is CLASS);

            Textbook       textbook2      = new Textbook("Textbook2", 700, "BindingT", "AuthorT", "Publishing HouseT");
            PrintedEdition printedEdition = textbook2 as PrintedEdition;


            IAction[] arr     = { journal0, textbook2, book1 };
            Printer   printer = new Printer();

            for (int i = 0; i < arr.Length; i++)
            {
                printer.iAmPrinting(arr[i]);
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Test             test   = new Test("Kontrol", "Hard", 10);
            Test             test2  = new Test("Obichni", "Easy", 10);
            Vopros           vopr   = new Vopros("", "Easy", 10);
            Ekzamen          ekzam  = new Ekzamen("Math");
            VipusknoiEkzamen vipusk = new VipusknoiEkzamen();

            Console.WriteLine(test.Tst + " " + test.Diffic + " " + test.Maxb);
            test.Tst = "Kontrolni";
            Console.WriteLine(test2.Tst + " " + test2.Diffic + " " + test2.Maxb);
            Console.WriteLine("------------------");
            test.ToConsole();
            test.Info();
            Console.WriteLine("------------------");
            test2.ToConsole();
            test2.Info();
            Console.WriteLine("------------------");
            // работа с одноименными методами
            test.TotJe();
            ((ITakoije)test).TotJe();
            Console.WriteLine("------------------");
            ((test2 as ITakoije)).TotJe(); // работа по ссылке (as)
            test2.TotJe();
            Console.WriteLine(test.Tst is string? "is" : "is not");
            Console.WriteLine("------------------");
            Printer.iAmPrinting(test);
            Printer.iAmPrinting(test2);
            Printer.iAmPrinting(vopr);
            object[] mas = { test, test2, vopr, ekzam, vipusk };
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            operationvirus virus  = new operationvirus(17, "trol", "ilya");//4 реализация этих интерефейсов
            dovirus        virus1 = virus as dovirus;

            virus1.hack();
            NotDovirus virus2 = (NotDovirus)virus;//работа с интерфейсом и его методами

            virus2.hack();
            //5
            Console.WriteLine(virus2.ToString());//вызов переорпделенного метода
            Developer[] a = new Developer[4];
            a[0] = new PO("ilya", "bstu");
            a[1] = new OperationWord(5, 20, "doc1", "ff", "hello", "firstdocument");
            a[2] = new saper("firstgame", "lego", "kemperast");
            a[3] = new virus(700, "troyan", "noname");
            Printer k = new Printer();

            k.iAmPrinting(a[0]);
        }