示例#1
0
        static void Main(string[] args)
        {
            var geometricFigures = new List <GeometricFigure>();

            var square             = new Square(50);
            var rectangle          = new Rectangle(50, 50);
            var parallelogram      = new Parallelogram(50, 50, 50);
            var triangle           = new Triangle(50, 50, 50, 50);
            var trapeze            = new Trapeze(50, 50, 50, 50, 70);
            var circle             = new Circle(50);
            var cube               = new Cube(50);
            var cylinder           = new Cylinder(50, 50);
            var cone               = new Cone(50, 50, 50);
            var sphere             = new Sphere(50);
            var regularTetrahedron = new RegularTetrahedron(50);

            geometricFigures.Add(square);
            geometricFigures.Add(rectangle);
            geometricFigures.Add(parallelogram);
            geometricFigures.Add(triangle);
            geometricFigures.Add(trapeze);
            geometricFigures.Add(circle);
            geometricFigures.Add(cube);
            geometricFigures.Add(cylinder);
            geometricFigures.Add(cone);
            geometricFigures.Add(sphere);
            geometricFigures.Add(regularTetrahedron);

            double totalArea = 0;
            double totalPerimeterOrVolume = 0;

            foreach (var geometricFigure in geometricFigures)
            {
                Console.WriteLine(geometricFigure);
                totalArea += geometricFigure.Area();
                totalPerimeterOrVolume += geometricFigure.PerimeterOrVolumen();
            }

            Console.WriteLine("==============================================");
            Console.WriteLine($"Total Area...............: {totalArea,15:N5}");
            Console.WriteLine($"Total Perimeter or Volume: {totalPerimeterOrVolume,15:N5}");
            Console.WriteLine("Press ENTER to finish...");
            Console.ReadKey();
        }
示例#2
0
        static void Main(string[] args)
        {
            var square        = new Square(50);
            var rectangle     = new Rectangle(50, 50);
            var parallelogram = new Parallelogram(50, 50, 50);
            var triangle      = new Triangle(50, 50, 50, 50);
            var trapeze       = new Trapeze(50, 50, 50, 50, 70);
            var circle        = new Circle(50);
            var cube          = new Cube(50);
            var cylinder      = new Cylinder(50, 50);
            var cone          = new Cone(50, 50, 50);
            var sphere        = new Sphere(50);
            //var regularTetrahedron = new RegularTetrahedron(50);

            var objGeometricsFigure = new List <GeometricFigure>();

            objGeometricsFigure.Add(square);
            objGeometricsFigure.Add(rectangle);
            objGeometricsFigure.Add(parallelogram);
            objGeometricsFigure.Add(triangle);
            objGeometricsFigure.Add(trapeze);
            objGeometricsFigure.Add(circle);
            objGeometricsFigure.Add(cube);
            objGeometricsFigure.Add(cylinder);
            objGeometricsFigure.Add(cone);
            objGeometricsFigure.Add(sphere);

            double area = 0;
            double perimeterOrVolume = 0;

            foreach (var figure in objGeometricsFigure)
            {
                Console.WriteLine(figure.ToString());
                area += figure.Area();
                perimeterOrVolume += figure.PerimeterOrVolumen();
            }

            Console.WriteLine("===================================");
            Console.WriteLine($"Total Area...............:{area,12:N2}");
            Console.WriteLine($"Total Perimeter or Volume:{perimeterOrVolume,12:N2}");
            Console.WriteLine("press enter to finish");
            Console.ReadKey();
        }
示例#3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Quadrangle");
            Quadrangle quadrangle = new Quadrangle(11, 12, 13, 14);

            Console.WriteLine("Area:" + quadrangle.Area());
            Console.WriteLine("Perimeter:" + quadrangle.Perimeter() + "\n");

            Console.WriteLine("Square");
            Square square = new Square(10);

            Console.WriteLine("Area:" + square.Area());
            Console.WriteLine("Perimeter:" + square.Perimeter() + "\n");

            Console.WriteLine("Rectangle");
            Rectangle rectangle = new Rectangle(11, 10);

            Console.WriteLine("Area:" + rectangle.Area());
            Console.WriteLine("Perimeter:" + rectangle.Perimeter() + "\n");

            Console.WriteLine("Rhomb");
            Rhomb rhomb = new Rhomb(10, 11);

            Console.WriteLine("Area:" + rhomb.Area());
            Console.WriteLine("Perimeter:" + rhomb.Perimeter() + "\n");

            Console.WriteLine("Parallelogram");
            Parallelogram parallelogram = new Parallelogram(11, 10.5, 8.7);

            Console.WriteLine("Area:" + parallelogram.Area());
            Console.WriteLine("Perimeter:" + parallelogram.Perimeter() + "\n");

            Console.WriteLine("Trapeze");
            Trapeze trapeze = new Trapeze(11, 13, 12, 8, 14);

            Console.WriteLine("Area:" + trapeze.Area());
            Console.WriteLine("Perimeter:" + trapeze.Perimeter() + "\n");

            Console.WriteLine("Triangle");
            Triangle triangle = new Triangle(6, 4.5, 7, 8);

            Console.WriteLine("Area:" + triangle.Area());
            Console.WriteLine("Perimeter:" + triangle.Perimeter() + "\n");

            Console.WriteLine("Circle");
            Circle circle = new Circle(10.5);

            Console.WriteLine("Area:" + circle.Area());
            Console.WriteLine("Perimeter:" + circle.Perimeter() + "\n");

            Console.WriteLine("Ellipse");
            Ellipse ellipse = new Ellipse(5.6, 4);

            Console.WriteLine("Area:" + ellipse.Area());
            Console.WriteLine("Perimeter:" + ellipse.Perimeter() + "\n");

            Console.WriteLine("Sphere");
            Sphere sphere = new Sphere(5.5);

            Console.WriteLine("Area:" + sphere.AreaSphere());
            Console.WriteLine("Volume:" + sphere.VolumeSphere() + "\n");
        }