Beispiel #1
0
        static void Main(string[] args)
        {
            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);

            if (box.Height != 0 && box.Length != 0 && box.Width != 0)
            {
                Console.WriteLine($"Surface Area - {box.Surface():F2}");
                Console.WriteLine($"Lateral Surface Area - {box.LateralSurface():F2}");
                Console.WriteLine($"Volume - {box.Volume():F2}");
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var length = decimal.Parse(Console.ReadLine());
            var width  = decimal.Parse(Console.ReadLine());
            var height = decimal.Parse(Console.ReadLine());

            Type boxType = typeof(Box);

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

            try
            {
                var box = new Box(length, width, height);
                Console.WriteLine($"Surface Area - {box.SurfaceArea():f2}");
                Console.WriteLine($"Lateral Surface Area - {box.LateralSurfaceArea():f2}");
                Console.WriteLine($"Volume - {box.Volume():f2}");
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        static void Main(string[] args)
        {
            try
            {
                var box = new Box();

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

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

                Console.WriteLine(box.SurfaceArea(length, width, height));
                Console.WriteLine(box.LateralSurfaceArea(length, width, height));
                Console.WriteLine(box.Volume(length, width, height));
            }

            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }