Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Circle figure       = new Circle(30, 50, 60);
            Circle clonedFigure = figure.Clone() as Circle;

            //---------Example of deep copy
            figure.GetInfo();
            clonedFigure.GetInfo();

            figure.Radius = 1000;

            figure.GetInfo();
            clonedFigure.GetInfo();
            //---------Example of deep copy

            //---------Example of shalow copy
            //---------But class doesn't contain referense type
            Rectangle rectangle       = new Rectangle(20, 40);
            Rectangle clonedRectangle = rectangle.Clone() as Rectangle;

            rectangle.GetInfo();
            clonedRectangle.GetInfo();

            Console.ReadKey();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Circle circle1 = new Circle(10);
            Circle circle2;

            circle2 = (Circle)circle1.clone();

            circle1.GetInfo();
            circle2.GetInfo();


            Rectangle rectangle1 = new Rectangle(10, 3);
            Rectangle rectangle2;

            rectangle2 = (Rectangle)rectangle1.clone();

            rectangle1.GetInfo();
            rectangle2.GetInfo();

            /* OUTPUT
             * Shape of this Circle: 10
             * Shape of this Circle: 10
             * Shape of this Rectangle: 2x3
             * Shape of this Rectangle: 2x3
             */
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Circle figure       = new Circle(30, 50, 60);
            Circle clonedFigure = figure.DeepCopy() as Circle;

            figure.Point.X = 100;
            figure.GetInfo();
            clonedFigure.GetInfo();

            Console.Read();
        }
Ejemplo n.º 4
0
        public void Run()
        {
            Circle figure = new Circle(30, 50, 60);

            // применяем глубокое копирование
            Circle clonedFigure = figure.DeepCopy() as Circle;

            figure.Point.X = 100;
            figure.GetInfo();
            clonedFigure.GetInfo();

            Console.Read();
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            IFigure figure       = new Rectangle(30, 40);
            IFigure clonedFigure = figure.Clone();

            figure.GetInfo();
            clonedFigure.GetInfo();

            figure       = new Circle(30);
            clonedFigure = figure.Clone();
            figure.GetInfo();
            clonedFigure.GetInfo();
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            IFigure figure       = new Rectangle(30, 40);
            IFigure clonedFigure = figure.Clone();

            figure.GetInfo();
            clonedFigure.GetInfo();

            Circle figure1       = new Circle(5, 4, 2);
            Circle clonedFigure1 = figure1.Clone() as Circle;

            figure1.GetInfo();
            clonedFigure1.GetInfo();
            Console.ReadKey();
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            IFigure figure      = new Rectangle(12, 12);
            IFigure figureClone = figure.Clone();

            figure.GetInfo();
            figureClone.GetInfo();


            figure      = new Circle(30);
            figureClone = figure.Clone();
            figure.GetInfo();
            figureClone.GetInfo();

            Console.ReadLine();
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            IFigure figure       = new Rectangle(10, 20);
            IFigure clonedFigure = figure.Clone();

            figure.GetInfo();
            clonedFigure.GetInfo();
            figure       = new Circle(15);
            clonedFigure = figure.Clone();
            figure.GetInfo();
            clonedFigure.GetInfo();
            figure       = new Triangle(10, 20, 25);
            clonedFigure = figure.Clone();
            figure.GetInfo();
            clonedFigure.GetInfo();
        }
Ejemplo n.º 9
0
        private static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Title           = "Prototype";

            IFigure figure       = new Rectangle(30, 40);
            var     clonedFigure = figure.Clone();

            figure.GetInfo();
            clonedFigure.GetInfo();

            figure       = new Circle(30);
            clonedFigure = figure.Clone();
            figure.GetInfo();
            clonedFigure.GetInfo();

            Console.ReadKey();
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;

            IFigure figure       = new Rectangle(10, 20);
            IFigure clonedFigure = figure.Clone();

            figure.GetInfo();
            clonedFigure.GetInfo();

            figure       = new Circle(15);
            clonedFigure = figure.Clone();
            figure.GetInfo();
            clonedFigure.GetInfo();

            figure       = new Triangle(3, 4, 5);
            clonedFigure = figure.Clone();
            figure.GetInfo();
            clonedFigure.GetInfo();

            Console.Read();
        }