Example #1
0
        public static void Main(string[] args)
        {
            var rectangles = new[]
            {
                new Rectangle {
                    Width = 10, Height = 5
                },
                new Rectangle {
                    Width = 4, Height = 6
                },
                new Rectangle {
                    Width = 5, Height = 1
                },
                new Rectangle {
                    Width = 8, Height = 9
                }
            };

            var sumAreas      = AreaOperation.Sum(rectangles);
            var sumPerimeters = PerimeterOperation.Sum(rectangles);

            Console.WriteLine($"Total Area: {sumAreas}");
            Console.WriteLine($"Total Perimeters: {sumPerimeters}");

            Console.ReadKey();
        }
        public static void Main(string[] args)
        {
            var figures = new IGeometricShape[]
            {
                new Rectangle {
                    Width = 10, Height = 5
                },
                new EquilateralTriangle {
                    SideLength = 5
                },
                new Rectangle {
                    Width = 4, Height = 6
                },
                new Rectangle {
                    Width = 8, Height = 9
                },
                new EquilateralTriangle {
                    SideLength = 5
                }
            };

            var sumAreas      = AreaOperation.Sum(figures);
            var sumPerimeters = PerimeterOperation.Sum(figures);

            Console.WriteLine($"Total Area: {sumAreas}");
            Console.WriteLine($"Total Perimeters: {sumPerimeters}");

            Console.ReadKey();
        }
        public void Calculate(IEnumerable <IGeometricShape> figures)
        {
            var geometricShapes = figures as IGeometricShape[];

            TotalAreas      = AreaOperation.Sum(geometricShapes);
            TotalPerimeters = PerimeterOperation.Sum(geometricShapes);
        }