Пример #1
0
        public void CalculateSummaryArea()
        {
            var rectangle  = new Rectangle(5, 6);
            var circle     = new Circle(3 / Math.Sqrt(Math.PI));
            var rectangle1 = new Rectangle(5, 6);
            var circle1    = new Circle(3 / Math.Sqrt(Math.PI));
            var square     = new Square(2);
            var square1    = new Square(2);
            var trapezium  = new Trapezium(3, 2, 3, 3);
            var trapezium1 = new Trapezium(2, 2, 2, 2);
            var triangle   = new Triangle(17, 17, 30);
            var triangle1  = new Triangle(17, 17, 30);
            var shapes     = new HashSet <IShape>()
            {
                circle, circle1,
                rectangle, rectangle1,
                square, square1,
                trapezium, trapezium1,
                triangle, triangle1
            };

            //Expected result calculated by me
            Assert.Equal(78, _shapeService.CalculateSummaryArea(shapes));
        }
Пример #2
0
        static void Main(string[] args)
        {
            var rectangle = new Rectangle(5, 6);
            var circle    = new Circle(3 / Math.Sqrt(Math.PI));
            var square    = new Square(2);
            var trapezium = new Trapezium(3, 7, 5, 4);
            var triangle  = new Triangle(17, 17, 30);
            var shapes    = new HashSet <IShape>()
            {
                circle, rectangle, square, trapezium, triangle
            };
            var shapeService = new ShapeService();

            Console.WriteLine(shapeService.CalculateSummaryArea(shapes));
            Console.WriteLine(shapeService.CalculateSummaryPerimeter(shapes));
        }