コード例 #1
0
ファイル: AreaCalculatorTest.cs プロジェクト: Rar4ik/MindBox
        public void GetTriangleArea()
        {
            var triangleObj = new Triangle();

            triangleObj.MainSide = 1;
            triangleObj.SideB    = 2;
            triangleObj.SideC    = 2;

            var triangle = new AreaCalculator(triangleObj);
            var expected = 0.97;

            var result = triangle.GetTriangleArea();

            Assert.Equal(expected, result);
        }
コード例 #2
0
ファイル: ShapeChooser.cs プロジェクト: Rar4ik/MindBox
 public double GetShape(IShape shape)
 {
     if (shape is Circle)
     {
         AreaCalculator areaCalculator = new AreaCalculator((Circle)shape);
         var            areaOfCircle   = areaCalculator.GetCircleArea();
         return(areaOfCircle);
     }
     else
     {
         AreaCalculator areaCalculator = new AreaCalculator((Triangle)shape);
         var            areaOfTriangle = areaCalculator.GetTriangleArea();
         return(areaOfTriangle);
     }
 }