示例#1
0
        private void PolygonCreationMenu()
        {
            Console.WriteLine("Polygon creation menu:\n" +
                              "Choose a polygon to create\n" +
                              "Square - 1\n" +
                              "Rectangle - 2\n" +
                              "Parallelogram - 3\n" +
                              "Triangle - 4\n" + // #TODO Fix triangle exception
                              "Trapeze - 5\n" +
                              "Custom - 6\n" +
                              "Back - b\n");

            Console.Write("Input: ");
            string input = Console.ReadLine();

            Console.WriteLine();

            Figure        figure = null;
            List <Coords> coords = null;

            Console.Clear();

            try
            {
                switch (input)
                {
                case "1":
                    coords = ReadCoords(4);
                    if (coords != null)
                    {
                        figure = _interactor.CreatePolygon("square", coords);
                    }

                    break;

                case "2":
                    coords = ReadCoords(4);

                    if (coords != null)
                    {
                        figure = _interactor.CreatePolygon("rectangle", coords);
                    }

                    break;

                case "3":
                    coords = ReadCoords(4);

                    if (coords != null)
                    {
                        figure = _interactor.CreatePolygon("parallelogram", coords);
                    }

                    break;

                case "4":
                    coords = ReadCoords(3);

                    if (coords != null)
                    {
                        figure = _interactor.CreatePolygon("triangle", coords);
                    }

                    break;

                case "5":
                    coords = ReadCoords(4);

                    if (coords != null)
                    {
                        figure = _interactor.CreatePolygon("trapeze", coords);
                    }

                    break;

                case "6":
                    Console.Write("Enter the amount of apexes: ");
                    int amount = Int32.Parse(Console.ReadLine());
                    Console.WriteLine();

                    coords = ReadCoords(amount);

                    if (coords != null)
                    {
                        figure = _interactor.CreatePolygon("custom", coords);
                    }

                    break;

                case "b":
                    Console.Clear();
                    return;
                }
            }
            catch (Exception e)
            {
                Console.Clear();
                ConsoleView.ColorizeError(e.Message);
                Console.WriteLine();
            }

            if (figure != null)
            {
                Console.Clear();
                _interactor.SetFigure(figure);
                PolygonParamsMenu();
            }
            else
            {
                PolygonCreationMenu();
            }
        }
示例#2
0
        private void PolyhedronCreationMenu()
        {
            Figure polygon = PolyhedronChoosingMenu();

            if (polygon == null || polygon is Polygon == false)
            {
                CreateFigureMenu();

                return;
            }

            Console.WriteLine("Polyhedron creation menu:\n" +
                              "Choose a polyhedron to create\n" +
                              "Cube - 1\n" +
                              "Parallelepiped - 2\n" +
                              "Prism - 3\n" +
                              "Pyramid - 4\n" +
                              "Back - b\n");

            Console.Write("Input: ");
            string input = Console.ReadLine();

            Console.WriteLine();

            Figure figure = null;
            double height = 0;

            switch (input)
            {
            case "1":
                Console.Clear();

                figure = _interactor.CreatePolyhedron("cube", (Polygon)polygon);

                break;

            case "2":
                Console.Write("Enter the height : ");
                height = Double.Parse(Console.ReadLine());
                Console.WriteLine();

                Console.Clear();

                figure = _interactor.CreatePolyhedron("parallelepiped", (Polygon)polygon, height);

                break;

            case "3":
                Console.Write("Enter the height : ");
                height = Double.Parse(Console.ReadLine());
                Console.WriteLine();

                Console.Clear();

                figure = _interactor.CreatePolyhedron("prism", (Polygon)polygon, height);

                break;

            case "4":
                Console.Write("Enter the height : ");
                height = Double.Parse(Console.ReadLine());
                Console.WriteLine();

                Console.Clear();

                figure = _interactor.CreatePolyhedron("pyramid", (Polygon)polygon, height);

                break;

            case "b":
                Console.Clear();

                return;
            }

            if (figure != null)
            {
                _interactor.SetFigure(figure);
                PolyhedronParamsMenu();
            }
            else
            {
                PolyhedronCreationMenu(); // #TODO Create a new line
            }
        }
示例#3
0
 public void SetFigure(Figure figure)
 {
     _figure = figure;
 }