Beispiel #1
0
        public ITriangle Create(double edgeLength, double angleA, double angleB)
        {
            TriangleFactory factory;

            if (IsTriangleEquilateral(edgeLength, angleA, angleB))
            {
                factory = new EquilateralTriangleFactory();
            }
            else if (IsTriangleIsosceles(edgeLength, angleA, angleB))
            {
                factory = new IsoscelesTriangleFactory();
            }
            else if (IsTriangleRight(edgeLength, angleA, angleB))
            {
                factory = new RightTriangleFactory();
            }
            else
            {
                factory = new ArbitraryTriangleFactory();
            }
            ITriangle triangle = factory.Create(edgeLength, angleA, angleB);

            Triangles ??= new List <ITriangle>();
            Triangles.Add(triangle);
            return(triangle);
        }
        public void HandleEvent()
        {
            isoscelesTriangleFactory = new IsoscelesTriangleFactory();
            Canvas.CurFigureFactory  = isoscelesTriangleFactory;
            MouseEventArgs eMouse = (MouseEventArgs)E;

            Canvas.PrevPoint = new PointF(eMouse.X, eMouse.Y);
        }