Example #1
0
        public void TestSquareTrinangleArgumentExc()  // недостаточно аргументов
        {
            ShapeCreator tc = new TriangleCreator();
            Shape        actual;

            Assert.Throws <ArgumentException>(() => actual = tc.Create(4, 3));
        }
Example #2
0
        public void TestSquareTrinangleSignedSide() // отрицательная сторона
        {
            ShapeCreator tc = new TriangleCreator();
            Shape        actual;

            Assert.Throws <ArgumentException>(() => actual = tc.Create(-5, 4, 3));
        }
Example #3
0
        public void TestSquareTrinangle()
        {
            ShapeCreator tc        = new TriangleCreator();
            var          triangle1 = tc.Create(5, 4, 3);
            double       actual    = triangle1.Square();
            double       expected  = 6;

            Assert.AreEqual(actual, expected);
        }
Example #4
0
    void Start()
    {
        body            = transform.GetChild(0);
        triangleCreator = body.GetComponent <TriangleCreator>();

        movementGrid       = GridManager.instance.GetGrid("movementGrid");
        currentGridIndex   = movementGrid.GetCenterIndex();
        transform.position = movementGrid.GetCenterPosition();
    }
Example #5
0
        public void Reset()
        {
            ShapeTypesInfoMap.Clear();

            RegisterShapeType(LineCreator.getInstance(), StandardLineRenderer.getInstance());
            RegisterShapeType(RectangleCreator.getInstance(), StandardRectangleRenderer.getInstance());
            RegisterShapeType(SquareCreator.getInstance(), StandardRectangleRenderer.getInstance());
            RegisterShapeType(EllipseCreator.getInstance(), StandardEllipseRenderer.getInstance());
            RegisterShapeType(CircleCreator.getInstance(), StandardEllipseRenderer.getInstance());
            RegisterShapeType(TriangleCreator.getInstance(), StandardTriangleRenderer.getInstance());
        }
Example #6
0
        public void CreateTriangle()
        {
            // Console.WriteLine av den här med base 5 ska se ut såhär
            // #
            // ##
            // ###
            // ####
            // #####
            var triangleCreator = new TriangleCreator();

            triangleCreator.create(5).ShouldBe($"#{Environment.NewLine}##{Environment.NewLine}###{Environment.NewLine}####{Environment.NewLine}#####");
        }
Example #7
0
        static void Main(string[] args)
        {
            ShapeCreator cc      = new CircleCreator();
            var          circle1 = cc.Create(3); // аргумент - радиус
            var          circle2 = cc.Create(5);

            Console.WriteLine(circle1.Square() + " " + circle1.name);

            ShapeCreator tc        = new TriangleCreator();
            var          triangle1 = tc.Create(5, 4, 3); // аргументы - стороны

            Console.WriteLine(triangle1.Square() + " " + triangle1.name);
            if (Triangle.RightAngle((Triangle)triangle1))
            {
                Console.WriteLine("Right");
            }
        }
Example #8
0
        private void ComboBoxFigures_SelectedIndexChanged(object sender, EventArgs e)
        {
            var figureName = ComboBoxFigures.SelectedItem as string;


            switch (figureName)
            {
            case "Rectangle":
                FigureCreator = new RectangleCreator();
                break;

            case "Circle":
                FigureCreator = new CircleCreator();
                break;

            case "Triangle":
                FigureCreator = new TriangleCreator();
                break;

            default:
                break;
            }
        }
 public string RenderingShapeTypeName()
 {
     return(TriangleCreator.getInstance().ShapeTypeName());
 }
Example #10
0
        static void Main(string[] args)
        {
            IFigureCreator[] creator = new IFigureCreator[6];
            creator[0] = new LUpCreator();
            creator[1] = new VerticalCreator();
            creator[2] = new LDownCreator();
            creator[3] = new ZetCreator();
            creator[4] = new ZetReverseCreator();
            creator[5] = new TriangleCreator();
            foreach (var item in creator)
            {
                //get the figure type and then with if set the color
                Figure figure = item.Creator();
                if (figure.Color == 1)
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                }
                else if (figure.Color == 2)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                }
                else if (figure.Color == 3)
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                }
                else if (figure.Color == 4)
                {
                    Console.ForegroundColor = ConsoleColor.Cyan;
                }
                else if (figure.Color == 5)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.White;
                }

                /*put all values in the list for check, this allows to avoid
                 * tostring override requirement*/
                var list = figure.Geometry;

                //counter to get into next line
                int count = 0;
                foreach (var number in list)
                {
                    if (number == 1)
                    {
                        Console.Write("1 ");
                    }
                    else
                    {
                        Console.Write("  ");
                    }
                    ++count;
                    if (count == 4)
                    {
                        count = 0;
                        Console.WriteLine();
                    }
                }
                Console.WriteLine();
            }
        }