Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Producer Kail    = new Producer();
            Person   person  = new Person();
            Person   persona = Kail;

            if (person is Producer)
            {
                Producer Igor = (Producer)person;
            }
            else
            {
                Console.WriteLine("Преобразовать нельзя");
            }
            Producer Lip = person as Producer;

            if (Lip == null)
            {
                Console.WriteLine("Преобразование прошло неудачно");
            }
            else
            {
                Console.WriteLine("Преобразование удалось");
            }


            Kail.name = "Kail";

            Kail.Move();
            Console.WriteLine(Kail.ToString());
            Console.WriteLine(persona.name);
            Film Transformers = new Film(2005);
            Film Hello        = new Film(2003);

            Transformers.time = 245;
            Cartoon Naruto = new Cartoon(6);
            News    GC     = new News(21);
            News    LL     = new News(18);
            Printer Print  = new Printer();

            Transformers.Watch();
            Naruto.Watch();
            GC.Watch();
            ProgramGuide Hai = new ProgramGuide();

            Hai.Year = 2015;
            ProgramGuide Hai2 = new ProgramGuide();

            Hai.Year = 2003;
            ProgramGuide Hai3 = new ProgramGuide();

            Hai.Year = 2015;
            ProgramGuide Hai4 = new ProgramGuide(200);

            Hai.Year = 2007;



            List <object> array = new List <object>()
            {
                Kail, person, Naruto, GC, Transformers, Print
            };

            foreach (object ch in array)
            {
                Print.IAmPrinting(ch);
            }
            List <ProgramGuide> film = new List <ProgramGuide>()
            {
                Hai, Hai2, Hai3
            };

            film.Add(Hai4);
            Controller.Count();
            Controller.Search(film);
            Hai4.Inf();

            // 7 Laba

            try
            {
                User     Andrey = new User("Andrey", 19);
                Film     Hello1 = new Film(2003);
                Film     Hello2 = new Film(-200); // error1
                int      a      = 0;
                int      b      = 100 / a;        // eror2
                string[] kre    = new string[5];
                kre[5] = "dfr";                   // error3
                News QWE  = new News(2888);       // error4
                User Igor = new User("", -30);
                Igor.Info();                      // error5

                int?pointer = null;
                Assert(pointer != null, "переменная равна -- null");
            }
            catch (NullStringException e)
            {
                Console.WriteLine(e);
            }
            catch (IndexOutOfRangeException e)
            {
                Console.WriteLine(e);
            }
            catch (YearException e)
            {
                Console.WriteLine(e);
            }
            catch (AgeLimitException e)
            {
                Console.WriteLine(e);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                Console.WriteLine("Проверка завершена!");
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Producer Kail    = new Producer();
            Person   person  = new Person();
            Person   persona = Kail;

            if (person is Producer)
            {
                Producer Igor = (Producer)person;
            }
            else
            {
                Console.WriteLine("Преобразовать нельзя");
            }
            Producer Lip = person as Producer;

            if (Lip == null)
            {
                Console.WriteLine("Преобразование прошло неудачно");
            }
            else
            {
                Console.WriteLine("Преобразование удалось");
            }


            Kail.name = "Kail";

            Kail.Move();
            Console.WriteLine(Kail.ToString());
            Console.WriteLine(persona.name);
            Film Transformers = new Film(2005);
            Film Hello        = new Film(2003);

            Transformers.time = 245;
            Cartoon Naruto = new Cartoon(6);
            News    GC     = new News(21);
            News    LL     = new News(18);
            Printer Print  = new Printer();

            Transformers.Watch();
            Naruto.Watch();
            GC.Watch();
            ProgramGuide Hai = new ProgramGuide();

            Hai.Year = 2015;
            ProgramGuide Hai2 = new ProgramGuide();

            Hai.Year = 2003;
            ProgramGuide Hai3 = new ProgramGuide();

            Hai.Year = 2015;
            ProgramGuide Hai4 = new ProgramGuide(200);

            Hai.Year = 2007;



            List <object> array = new List <object>()
            {
                Kail, person, Naruto, GC, Transformers, Print
            };

            foreach (object ch in array)
            {
                Print.IAmPrinting(ch);
            }
            List <ProgramGuide> film = new List <ProgramGuide>()
            {
                Hai, Hai2, Hai3
            };

            film.Add(Hai4);
            Controller.Count();
            Controller.Search(film);
            Hai4.Inf();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            int x = 5;
            int X = (x == 3 ? x:x = 4);

            Console.WriteLine(X);
            return;

            Cartoon cartoon = new Cartoon("Hazbin Hotel", Color.All);

            Console.WriteLine(cartoon);
            if (cartoon.color.HasFlag(Color.Red))
            {
                Console.WriteLine($"It is {Color.Red}");
            }
            if (cartoon.color.HasFlag(Color.Yellow))
            {
                Console.WriteLine($"It is {Color.Yellow}");
            }
            if (cartoon.color.HasFlag(Color.Black))
            {
                Console.WriteLine($"It is {Color.Black}");
            }
            if (cartoon.color.HasFlag(Color.All))
            {
                Console.WriteLine($"It is {Color.All}");
            }
            if (cartoon.color.HasFlag(Color.All2))
            {
                Console.WriteLine($"It is {Color.All2}");
            }
            if (cartoon.color.HasFlag(Color.White))
            {
                Console.WriteLine($"It is {Color.White}");
            }
            return;

            unsafe
            {
                int?a = null;
                int?b = null;
                int c = (a.HasValue ? a.Value : 2) + (b.HasValue ? b.Value : 7);
                Console.WriteLine(c);
                int *  z = &c;
                IntPtr p = (IntPtr)z;
                Console.WriteLine(p);
            }
            int    num    = 3;
            string result = "";

            switch (num)
            {
            case 1:
            {
                result = "It is 1";
                break;
            }

            case 2:
            {
                result = "It is 2";
                break;
            }

            case 3:
            {
                result = "It is 3";
                break;
            }

            default:
                result = "It is not possible";
                break;
            }
            Console.WriteLine(result);
        }