Пример #1
0
        public static void Main()
        {
            Type boxType = typeof(Box);

            FieldInfo[] fields = boxType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
            Console.WriteLine(fields.Count());
            var length = double.Parse(Console.ReadLine());
            var width  = double.Parse(Console.ReadLine());
            var height = double.Parse(Console.ReadLine());

            var box                = new Box(length, width, height);
            var surfaceArea        = box.CalculateSurfaceArea();
            var lateralSurfaceArea = box.CalculateLateralSurfaceArea();
            var volume             = box.CalculateVolume();

            PrintResult(surfaceArea, lateralSurfaceArea, volume);
        }
Пример #2
0
        public static void Main()
        {
            Type boxType = typeof(Box);

            FieldInfo[] fields = boxType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
            Console.WriteLine(fields.Count());

            double length = double.Parse(Console.ReadLine());
            double width  = double.Parse(Console.ReadLine());
            double height = double.Parse(Console.ReadLine());

            try
            {
                Box box = new Box(length, width, height);

                Console.WriteLine($"Surface Area - {box.CalculateSurface():f2}");
                Console.WriteLine($"Lateral Surface Area - {box.CalculateLateralSurface():f2}");
                Console.WriteLine($"Volume - {box.CalculateVolume():f2}");
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }
        }