Exemple #1
0
        private static void DisplayResults(IShapeRepository repository)
        {
            var shapes = repository.GetAll();

            var averageArea      = 0.0;
            var averagePerimeter = 0.0;

            if (shapes.Count > 0)
            {
                averageArea      = Math.Round(shapes.Select(x => x.Area()).Average(), 2);
                averagePerimeter = Math.Round(shapes.Select(x => x.Perimeter()).Average(), 2);
            }

            Console.WriteLine($"Average Area: {averageArea}");
            Console.WriteLine($"Average Perimeter: {averagePerimeter}");
        }
Exemple #2
0
        public List <Shape> GetShape()
        {
            var listCategory = new List <Shape>()
            {
                new Shape()
                {
                    Id   = 0,
                    Name = "Mẫu",
                }
            };
            var sampleCategory = ShapesRepository.GetAll().Select(
                x => new Shape()
            {
                Id   = x.Id,
                Name = x.Name
            }).ToList();

            listCategory.AddRange(sampleCategory);
            return(listCategory);
        }