예제 #1
0
        public IShape CreateShape(ShapeType shapeType)
        {
            IShape newShape;

            switch (shapeType)
            {
            case ShapeType.Circle:
                newShape = new Circle();
                break;

            case ShapeType.Rectangle:
                newShape = new Rectangle();
                break;

            case ShapeType.Square:
                newShape = new Square();
                break;

            default:
                newShape = new NullShape();
                break;
            }

            return(newShape);
        }
예제 #2
0
        public override IShape GetShape(ShapeType shapeType)
        {
            IShape shape = new NullShape();

            switch (shapeType)
            {
            case ShapeType.Circle:
                shape = new Circle();
                break;

            case ShapeType.Rectangle:
                shape = new Rectangle();
                break;

            case ShapeType.Square:
                shape = new Square();
                break;
            }
            return(shape);
        }