Esempio n. 1
0
        static void Main(string[] args)
        {
            Tovar    printerr1 = new Printerr("Canon", 1000, "Принтер", "Цветной");
            Tovar    printerr2 = new Printerr("Hp", 2000, "Принтер", "Цветной");
            Printerr printerr  = printerr1 as Printerr;                                         //идентификация типа объекта с помощью оператора as

            printerr.TypePrinter = "Ч/Б";                                                       //Теперь возможно обращение

            Tovar scaner1 = new Scaner("Canon", 500, "Сканер");
            Tovar scaner2 = new Scaner("Hp", 700, "Сканер");

            Tovar computer1 = new Computer("Lenovo", 5000, "Ноутбук");
            Tovar computer2 = new Computer("Hp", 4000, "Ноутбук");

            Tovar planshet1 = new Planshet("Lenovo", 1500, "Планшет");
            Tovar planshet2 = new Planshet("Samsung", 1800, "Планшет");

            printerr1.Display();
            printerr2.Display();

            //iAmPrinting
            Interes interes  = new Interes();
            Printer printer  = new Printer();
            object  printer1 = printer.iAmPrinting(interes);

            Console.WriteLine("Вызов метод iAmPrinting - " + printer);

            Console.ReadKey();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Product printer = new Printer(1, "Техника", 1200, 12);
            Product pC      = new PC(2, "Техника", 1500);
            Product scaner  = new Scaner(3, "Техника", 1100, 7);

            printer.Info();
            pC.Info();
            Client client = new Client("Vlad", 50000);

            client.Put(1200);
            client.Take(5000);
            WriteLine(client.CurrentSum);
            Output output = new Output();

            ((Text)output).print();
            ((Tuxt)output).print();
            BaseClient obj = client as BaseClient;

            obj = client;
            obj.Put(1321);
            WriteLine(obj.CurrentSum);
            IAccount obj2 = client as IAccount;

            obj2.Put(12);
            WriteLine(obj2.CurrentSum);
            WriteLine(pC.ToString());
            Printers printers = new Printers();
            var      mass     = new[] { pC, printer, scaner };

            for (int i = 0; i < 3; i++)
            {
                printers.IAmPrinting(mass[i]);
            }

            ReadKey();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Equipment printer  = new Printer(1, 2, "Принтер", 1200, 12);
            Equipment pC       = new PC(2, 4, "Компьютер", 1500);
            Equipment scaner   = new Scaner(3, 1, 1700, "Сканер", 7);
            Printer   printer1 = new Printer(4, 6, "Техника", 1762, 5);

            printer.Info();
            pC.Info();
            Client client = new Client("Vlad", 50000);

            client.Put(1200);
            client.Take(5000);
            WriteLine(client.CurrentSum);
            Output output = new Output();

            ((Text)output).print();
            ((Tuxt)output).print();
            BaseClient obj = client as BaseClient;

            obj = client;
            obj.Put(1321);
            WriteLine(obj.CurrentSum);
            IAccount obj2 = client as IAccount;

            obj2.Put(12);
            WriteLine(obj2.CurrentSum);
            WriteLine(pC.ToString());
            Printers printers = new Printers();
            var      mass     = new[] { pC, printer, scaner };

            for (int i = 0; i < 3; i++)
            {
                printers.IAmPrinting(mass[i]);
            }
            Person person = new Person();

            Write("Имя: ");
            person.name = ReadLine();
            WriteLine();
            Write("Возраст: ");

            person.age = Convert.ToInt32(ReadLine());
            Mounth mounth = Mounth.October;

            WriteLine(mounth + 1);
            printer1.ShowInfo();
            Control laboratory = new Control();

            laboratory.Push(pC);
            laboratory.Push(printer);
            laboratory.Push(scaner);
            laboratory.Show();
            WriteLine();
            laboratory.Count();
            laboratory.Age(3);

            laboratory.Librariary.Sort(laboratory);
            laboratory.Show();
            WriteLine();

            Man man = new Man();

            try
            {
                man.Money = 99;
            }
            catch (ManException ex)
            {
                WriteLine(ex.Message);
                StackTrace stackTrace = new StackTrace(ex, true);
                WriteLine(stackTrace);
            }
            catch (StrException ex)
            {
                WriteLine(ex.Message);
                StackTrace stackTrace = new StackTrace(ex, true);
                WriteLine(stackTrace);
            }
            catch (DivideByZeroException ex)
            {
                StackTrace stackTrace = new StackTrace(ex, true);
                WriteLine(stackTrace);
                WriteLine("Деление на ноль!");
            }
            catch (OverflowException ex)
            {
                WriteLine("Данное число не входит в диапазон");
                StackTrace stackTrace = new StackTrace(ex, true);
                WriteLine(stackTrace);
            }
            catch (MoneyException ex)
            {
                WriteLine(ex.Message + " he has " + ex.Money + "$");
                StackTrace stackTrace = new StackTrace(ex, true);
                WriteLine(stackTrace);
            }
            catch
            {
            }


            Prove();
            ReadKey();
        }