示例#1
0
        static void Main(string[] args)
        {
            Rectangle square = new Rectangle();

            square.Height = 10;
            square.Square();
            Circle circ = new Circle();

            ((IControlElement)square).Close();

            Rectangle rec = new Rectangle();

            Console.WriteLine("\n" + rec.Equals(square));
            rec = square;
            Console.WriteLine(rec.Equals(square));

            Console.WriteLine("\n" + square.DoClone());
            ((IControlElement)square).DoClone();

            IControlElement rec3 = new Rectangle();

            rec3.DoClone();

            Figure fl, f2;


            fl = new Circle();

            f2 = new Rectangle();

            Square sq  = new Square();
            Square sq1 = new Square();

            Printer p = new Printer();

            Figure[] fig = new Figure[4];
            fig[0] = sq;
            fig[1] = square;
            fig[2] = sq1;
            fig[3] = circ;
            for (int i = 0; i < 4; i++)
            {
                p.iAmPrinting(fig[i]);
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            Rectangle square = new Rectangle();

            square.Height = 10;
            square.Square_s();
            Circle circ = new Circle();

            ((IControlElement)square).Close();

            Rectangle rec = new Rectangle();

            Console.WriteLine("\n" + rec.Equals(square));
            rec = square;
            Console.WriteLine(rec.Equals(square));

            Console.WriteLine("\n" + square.DoClone());
            ((IControlElement)square).DoClone();

            Figure fl, f2;

            fl = new Circle();

            f2 = new Rectangle();

            Square sq  = new Square();
            Square sq1 = new Square();

            Printer p = new Printer();

            Figure[] fig = new Figure[4];
            fig[0] = sq;
            fig[1] = square;
            fig[2] = sq1;
            fig[3] = circ;
            for (int i = 0; i < 4; i++)
            {
                p.iAmPrinting(fig[i]);
            }

            sq1.A       = 5;
            sq.A        = 7;
            circ.Radius = 5;
            //6 lab
            UserInterface UI = new UserInterface();

            UI.AddtoList(sq1);
            UI.AddtoList(sq);
            UI.AddtoList(square);
            UI.AddtoList(circ);
            UI.ShowList();
            Console.WriteLine(Controller.Area(UI));
            Logger logger = new Logger();

            try
            {
                int a = 10;
                int b = 0;
                if (b != 0)
                {
                    Console.WriteLine(a / b);
                }
                else
                {
                    throw new NullExceptions("You can't divide by zero");
                }
            }
            catch (NullExceptions exception)
            {
                logger.Log(exception);
                exception.GetInfo();
            }

            try
            {
                UserInterface UI1 = new UserInterface();
                UI1.RemoveFromList(circ);
            }
            catch (EmptyExceptions exception)
            {
                logger.Log(exception);
                exception.GetInfo();
            }

            try
            {
                Rectangle rec100 = new Rectangle(-10);
            }
            catch (ConstructorExceptions exception)
            {
                logger.Log(exception);
                exception.GetInfo();
            }
            finally
            {
                Console.WriteLine("always executed");
            }
            int factorial(int n)
            {
                Debug.Assert(n >= 0, "Factorial of negative number does not count");


                Debug.Assert(n <= 10);

                if (n < 2)
                {
                    return(1);
                }

                return(factorial(n - 1) * n);
            }

            logger.ShowLog();
            logger.FileLog();
            Console.ReadKey();
            //factorial(-10);
        }
示例#3
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Cyan;
            Aviation aviation = new Aviation();
            Cargo    cargo    = new Cargo();
            Military military = new Military();
            Pasanger pasanger = new Pasanger();
            Ty134    ty134    = new Ty134();
            Boing    boing    = new Boing();

            cargo.addInfo();
            Console.WriteLine('\n');
            military.addInfo();
            Console.WriteLine('\n');
            pasanger.addInfo();
            Console.WriteLine('\n');

            Console.ForegroundColor = ConsoleColor.Magenta;
            aviation.Type();
            cargo.Type();
            military.Type();
            pasanger.Type();
            ty134.Type();
            boing.Type();
            Console.WriteLine('\n');

            Console.ForegroundColor = ConsoleColor.White;
            bool fly = pasanger is Aviation;

            if (fly)
            {
                Aviation confOne = (Aviation)pasanger;
                confOne.Type();
            }

            Console.ForegroundColor = ConsoleColor.Red;
            ITransport confTwo   = military as ITransport;
            ITrans     confThree = cargo as ITrans;

            if (confTwo != null)
            {
                confTwo.Info();
            }

            if (confThree != null)
            {
                confThree.Info("fsfe");
            }



            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine(cargo.ToString());

            Console.ForegroundColor = ConsoleColor.Green;
            Transport obj = pasanger as Transport;//можно ли преобразовать

            Console.WriteLine(obj.GetType());

            Console.ForegroundColor = ConsoleColor.Yellow;
            if (military is Transport)//преднадлежит
            {
                Console.WriteLine(true + "\n");
            }

            Console.ForegroundColor = ConsoleColor.Magenta;
            Transport[] mas = { cargo, military, pasanger };
            foreach (Transport x in mas)
            {
                Console.WriteLine(Printer.iAmPrinting(x));
            }

            Console.ReadKey();
        }