Пример #1
0
        private static Rectangle CreateRectangle(ShapeArgumentsParser shapeArgumentsParser)
        {
            if (shapeArgumentsParser.NextArgumentsCount != 5)
            {
                return(null);
            }

            ColorType shapeColor  = shapeArgumentsParser.GetNextAsColor();
            var       leftTop     = new Point(shapeArgumentsParser.GetNextAsDouble(), shapeArgumentsParser.GetNextAsDouble());
            var       rightBottom = new Point(shapeArgumentsParser.GetNextAsDouble(), shapeArgumentsParser.GetNextAsDouble());

            return(new Rectangle(leftTop, rightBottom, shapeColor));
        }
Пример #2
0
        private static Ellipse CreateEllipse(ShapeArgumentsParser shapeArgumentsParser)
        {
            if (shapeArgumentsParser.NextArgumentsCount != 5)
            {
                throw new ApplicationException("Ellipse is not created. Wrong count of parametrs");
            }

            ColorType shapeColor       = shapeArgumentsParser.GetNextAsColor();
            var       center           = new Point(shapeArgumentsParser.GetNextAsDouble(), shapeArgumentsParser.GetNextAsDouble());
            double    horizontalRadius = shapeArgumentsParser.GetNextAsDouble();
            double    verticalRadius   = shapeArgumentsParser.GetNextAsDouble();

            return(new Ellipse(center, horizontalRadius, verticalRadius, shapeColor));
        }
Пример #3
0
        private static RegularPolygon CreateRegularPolygon(ShapeArgumentsParser shapeArgumentsParser)
        {
            if (shapeArgumentsParser.NextArgumentsCount != 5)
            {
                throw new ApplicationException("RegularPolygon is not created. Wrong count of parametrs");
            }

            ColorType shapeColor  = shapeArgumentsParser.GetNextAsColor();
            int       vertexCount = shapeArgumentsParser.GetNextAsInt();
            double    radius      = shapeArgumentsParser.GetNextAsDouble();
            var       center      = new Point(shapeArgumentsParser.GetNextAsDouble(), shapeArgumentsParser.GetNextAsDouble());

            return(new RegularPolygon(vertexCount, radius, center, shapeColor));
        }
Пример #4
0
        private static Triangle CreateTriangle(ShapeArgumentsParser shapeArgumentsParser)
        {
            if (shapeArgumentsParser.NextArgumentsCount != 7)
            {
                throw new ApplicationException("Triangle is not created. Wrong count of parametrs");
            }

            ColorType shapeColor = shapeArgumentsParser.GetNextAsColor();

            var vertex1 = new Point(shapeArgumentsParser.GetNextAsDouble(), shapeArgumentsParser.GetNextAsDouble());
            var vertex2 = new Point(shapeArgumentsParser.GetNextAsDouble(), shapeArgumentsParser.GetNextAsDouble());
            var vertex3 = new Point(shapeArgumentsParser.GetNextAsDouble(), shapeArgumentsParser.GetNextAsDouble());

            return(new Triangle(vertex1, vertex2, vertex3, shapeColor));
        }