예제 #1
0
        static void Main(string[] args)
        {
            IShapeFactory circlefactory = new CircleFactory(); //新建圆形工厂类
            IShape        circle        = circlefactory.GetShape();

            circle.DrawShap();
            Console.WriteLine("Hello World!");
        }
예제 #2
0
        public static void Main()
        {
            ShapeFactory shape_factory = new SquareFactory();

            IShape shape1 = shape_factory.GetShape(4);

            Console.WriteLine("Shape Area: " + shape1.Area());
            Console.WriteLine("Shape Perimeter: " + shape1.Perimeter());

            shape_factory = new CircleFactory();
            IShape shape2 = shape_factory.GetShape(3);

            Console.WriteLine("Shape Area: " + shape2.Area());
            Console.WriteLine("Shape Perimeter: " + shape2.Perimeter());

            Console.ReadLine();
        }