Пример #1
0
 public Control2(Container2 po)
 {
     this.pr = po;
 }
Пример #2
0
        static void Main(string[] args)
        {
            //int[] diagnoz = null;
            //Debug.Assert(diagnoz != null, "значения массива не могут быть null");

            try
            {
                int f = int.Parse(Console.ReadLine());
                int q = int.Parse(Console.ReadLine());
                ExceptionExample(f, q);
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message + "\n\n");
                Console.Write(ex.TargetSite + "\n\n");
                Console.Write(ex.StackTrace + "\n\n");
                Console.Write(ex.HelpLink + "\n\n");
                if (ex.Data != null)
                {
                    Console.WriteLine("Свединия \n");
                    foreach (DictionaryEntry d in ex.Data)
                    {
                        Console.WriteLine("-> {0} {1}", d.Key, d.Value);
                        Console.WriteLine("\n\n");
                    }
                }
            }

            try
            {
                int zi = 300;
                if (zi > 255)
                {
                    throw new OverflowException();
                }
            }
            catch (OverflowException)
            {
                Console.WriteLine("Ошибка доступного диапазаона\n");
                //throw;
            }
            finally
            {
                //Environment.Exit(0);
            }

            int ki = 0;
            int kj = 0;

            try
            {
                ki = int.Parse(Console.ReadLine());
                kj = int.Parse(Console.ReadLine());
            }
            catch (Exception ex) when(ex.GetType() != typeof(System.DivideByZeroException))
            {
                Console.WriteLine("Всё кроме формата");
            }

            //int c;
            //int f = 13;
            //int q = 1;
            //if (q == 1)
            //{
            //    throw new Exception("Zero devision");
            //}
            //else
            //{
            //    c = f / q;
            //}



            Items obj1 = new KoncelarItems("Бумага", 50);

            Console.Write(" {0}", obj1.Vich(obj1.code1, obj1.code2));
            Console.WriteLine();
            KoncelarItems obj2 = new KoncelarItems("Цветы", 52);

            obj2.Show();
            Itrade obj3 = new Clock();

            obj3.Show();

            Sweets obj4 = new Sweets("Грельяш", 1);

            obj4.Show();
            Produce obj5 = new Produce("Комунарка", " Завод сладких изделий", 1980);

            Object[] mass = { obj1, obj2, obj3, obj4, obj5 };
            Console.WriteLine("-------------------------------------------");
            foreach (Object i in mass)
            {
                Itrade obj = (Itrade)i;
                obj.Show();
            }
            Console.WriteLine("-------------------------------------------");
            Printer obz = new Printer();

            Itrade[] mdk = { (Itrade)obj1, obj2, obj3 };
            foreach (Itrade i in mdk)
            {
                obz.iAmPrinting(i);
            }

            //AA my = new BB();
            AA my = new CC();

            my.woll();

            A lol = new B();
            //lol.ZZZ();

            J o1 = new Z();
            J o2 = new K();

            o1 = o2;

            ////////////////// struct //////////////////
            UserInfo user1 = new UserInfo("Alexandr", 26);

            Console.Write("user1: ");
            user1.WriteUserInfo();
            UserInfo user2 = new UserInfo("Elena", 22);

            Console.Write("user2: ");
            user2.WriteUserInfo();

            // Показать главное отличие структур от классов
            user1      = user2;
            user2.Name = "Natalya";
            user2.Age  = 25;
            Console.Write("\nuser1: ");
            user1.WriteUserInfo();
            Console.Write("user2: ");
            user2.WriteUserInfo();

            Console.ReadLine();
            ////////////////// struct //////////////////
            ////////////////// Enum //////////////////
            UI user;

            for (user = UI.Name; user <= UI.Sex; user++)
            {
                Console.WriteLine("Элемент: \"{0}\", значение {1}", user, (int)user);
            }
            ////////////////// Enum //////////////////
            Container b = new Container();

            b.byk = new List <Lampa>();
            Lampa swet1 = new Lampa();
            Lampa swet2 = new Lampa(10);
            Lampa swet3 = new Lampa(12);

            b.Add(swet1);
            b.Add(swet2);
            b.Add(swet3);
            Console.WriteLine("\n");
            Console.WriteLine("\n");
            b.Info();

            b.MasOfPresents();

            Console.WriteLine("----------------------------------------------------------------");
            Console.WriteLine("----------------------------------------------------------------");
            Console.WriteLine("----------------------------------------------------------------");
            Console.WriteLine("----------------------------------------------------------------");
            Console.WriteLine("----------------------------------------------------------------");
            Controller cont = new Controller();

            cont.Search(b.byk);
            cont.MassSorting(b.byk);
            foreach (Lampa p in b.byk)
            {
                Console.WriteLine(p.MassaPresenta + " " + p.namepr);
            }
            b.Info();

            Console.ReadKey();

            Container2 prr = new Container2();
            Control2   pis = new Control2(prr);

            pis.Install(new Lampa());
        }