Example #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());
            Box box    = null;

            try
            {
                box = new Box(length, width, height);
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
                return;
            }

            Console.WriteLine($"Surface Area - {box.SurfaceArea():F2}");
            Console.WriteLine($"Lateral Surface Area - {box.LateralSurfaceArea():F2}");
            Console.WriteLine($"Volume - {box.Volume():F2}");
        }
Example #2
0
        static void Main(string[] args)
        {
            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);

            Console.WriteLine($"Surface Area - {box.SurfaceArea():f2}");
            Console.WriteLine($"Lateral Surface Area - {box.LateralSerfaceArea():f2}");
            Console.WriteLine($"Volume - {box.Volume():f2}");
        }
Example #3
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());

            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}");
        }
Example #4
0
        public static void Main()
        {
            Type boxType = typeof(Box);

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

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


            var parallelepiped = new Box(width, length, height);

            Console.WriteLine($"Surface Area - {parallelepiped.SurfaceArea():f2}");
            Console.WriteLine($"Lateral Surface Area - {parallelepiped.LateralSurfaceArea():f2}");
            Console.WriteLine($"Volume - {parallelepiped.Volume():f2}");
        }
Example #5
0
        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);
            }
        }