示例#1
0
        static void Main(string[] args)
        {
            Circle c = new Circle(new Point(5, 5), 50.5);

            Console.WriteLine(c);

            DoStuffWithCircle((Circle)c.Clone());

            Console.WriteLine(c);

            Rectangle r = new Rectangle(new Point(5, 5), new Point(10, 5), new Point(5, 10), new Point(10, 10));

            Console.WriteLine(r);

            DoStuffWithRectangle((Rectangle)r.Clone());

            Console.WriteLine(r);

            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            ShapeHolder s1 = new ShapeHolder();

            s1.AddShape(c);
            s1.AddShape(r);

            Console.WriteLine(s1);

            DoStuffWithList((ShapeHolder)s1.Clone(), c);

            Console.WriteLine(s1);
        }
示例#2
0
        static void Main(string[] args)
        {
            Circle      c           = new Circle(new Point(5, 5), 50.5);
            Rectangle   r           = new Rectangle(new Point(0, 0), new Point(0, 5), new Point(5, 0), new Point(5, 5));
            ShapeHolder shapeHolder = new ShapeHolder();

            Console.WriteLine(c);
            Console.WriteLine(r);

            DoStuffWithCircle((Circle)c.clone());
            DoStuffWithRectangle((Rectangle)r.clone());

            Console.WriteLine(c);
            Console.WriteLine(r);

            shapeHolder.addShape(c);
            shapeHolder.addShape(r);

            Console.WriteLine(shapeHolder.clone());
        }
示例#3
0
 public static void DoStuffWithList(ShapeHolder s, ShapeBase newShape)
 {
     s.AddShape(newShape);
 }