Наследование: ITransformable
Пример #1
0
        public virtual void ExecuteFigureCreationCommand(string[] splitFigString)
        {
            switch (splitFigString[0])
            {
                case "vertex":
                    {
                        Vector3D location = Vector3D.Parse(splitFigString[1]);
                        currentFigure = new Vertex(location);
                        break;
                    }
                case "segment":
                    {
                        Vector3D a = Vector3D.Parse(splitFigString[1]);
                        Vector3D b = Vector3D.Parse(splitFigString[2]);
                        currentFigure = new LineSegment(a, b);
                        break;
                    }
                case "triangle":
                    {
                        Vector3D a = Vector3D.Parse(splitFigString[1]);
                        Vector3D b = Vector3D.Parse(splitFigString[2]);
                        Vector3D c = Vector3D.Parse(splitFigString[3]);
                        currentFigure = new Triangle(a, b, c);
                        break;
                    }
            }

            this.EndCommandExecuted = false;
        }
        public virtual void ExecuteFigureCreationCommand(string[] splitFigString)
        {
            switch (splitFigString[0])
            {
                case "vertex":
                    {
                        Vector3D location = Vector3D.Parse(splitFigString[1]);
                        currentFigure = new Vertex(location);
                        break;
                    }
                case "segment":
                    {
                        Vector3D a = Vector3D.Parse(splitFigString[1]);
                        Vector3D b = Vector3D.Parse(splitFigString[2]);
                        currentFigure = new LineSegment(a, b);
                        break;
                    }
                case "triangle":
                    {
                        Vector3D a = Vector3D.Parse(splitFigString[1]);
                        Vector3D b = Vector3D.Parse(splitFigString[2]);
                        Vector3D c = Vector3D.Parse(splitFigString[3]);
                        currentFigure = new Triangle(a, b, c);
                        break;
                    }
                    // adds "circle" command
                case "circle":
                    {
                        Vector3D center = Vector3D.Parse(splitFigString[1]);
                        double radius = double.Parse(splitFigString[2]);
                        currentFigure = new Circle(center, radius);
                        break;
                    }
                    // adds "cylinder" command
                case "cylinder":
                    {
                        Vector3D bottom = Vector3D.Parse(splitFigString[1]);
                        Vector3D top = Vector3D.Parse(splitFigString[2]);
                        double radius = double.Parse(splitFigString[3]);
                        currentFigure = new Cylinder(bottom, top, radius);
                        break;
                    }
            }

            this.EndCommandExecuted = false;
        }
Пример #3
0
        // Methods
        public void ExecuteCommand(string commandStr)
        {
            string[] splitCommand = commandStr.Split(FigureController.separators, StringSplitOptions.RemoveEmptyEntries);

            if (this.currentFigure == null)
            {
                this.ExecuteFigureCreationCommand(splitCommand);
            }
            else if (splitCommand[0] == "end")
            {
                this.currentFigure = null;
                this.EndCommandExecuted = true;
            }
            else
            {
                this.ExecuteFigureInstanceCommand(splitCommand);
            }
        }
Пример #4
0
 public FigureController()
 {
     this.currentFigure = null;
     this.EndCommandExecuted = false;
 }
Пример #5
0
        public virtual void ExecuteFigureCreationCommand(string[] splitFigString)
        {
            switch (splitFigString[0])
            {
                case "vertex":
                    {
                        Vector3D location = Vector3D.Parse(splitFigString[1]);
                        currentFigure = new Vertex(location);
                        break;
                    }
                case "segment":
                    {
                        Vector3D a = Vector3D.Parse(splitFigString[1]);
                        Vector3D b = Vector3D.Parse(splitFigString[2]);
                        currentFigure = new LineSegment(a, b);
                        break;
                    }
                case "triangle":
                    {
                        Vector3D a = Vector3D.Parse(splitFigString[1]);
                        Vector3D b = Vector3D.Parse(splitFigString[2]);
                        Vector3D c = Vector3D.Parse(splitFigString[3]);
                        currentFigure = new Triangle(a, b, c);
                        break;
                    }
                // case circle
                case "circle":
                    {
                        Vector3D a = Vector3D.Parse(splitFigString[1]);

                        double radius = double.Parse(splitFigString[2]);
                        currentFigure = new Circle(a, radius);
                        break;
                    }
                // case cylinder
                case "cylinder":
                    {
                        // cylinder (bottomX,bottomY,bottomZ) (topX, topY, topZ) radius
                        Vector3D a = Vector3D.Parse(splitFigString[1]);

                        Vector3D b = Vector3D.Parse(splitFigString[2]);
                        double radius = double.Parse(splitFigString[3]);
                        currentFigure = new Cylinder(a, b, radius);
                        break;
                    }
            }

            this.EndCommandExecuted = false;
        }
Пример #6
0
 public FigureController()
 {
     this.currentFigure      = null;
     this.EndCommandExecuted = false;
 }