Beispiel #1
0
        static void Main(string[] args)
        {
            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.SurfaceArea(box.Length, box.Width, box.Height):F2}");
                Console.WriteLine($"Lateral Surface Area - {Box.LateralSurface(box.Length, box.Width, box.Height):F2}");
                Console.WriteLine($"Volume - {Box.Volume(box.Length, box.Width, box.Height):F2}");
            } catch (ArgumentException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Type boxType = typeof(Box);

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

            //double length = double.Parse(Console.ReadLine());
            double[] input = new double[3];
            input[0] = double.Parse(Console.ReadLine());
            input[1] = double.Parse(Console.ReadLine());
            input[2] = double.Parse(Console.ReadLine());
            Box box = new Box(input[0], input[1], input[2]);

            Console.WriteLine("Surface Area - {0:f2}\nLateral Surface Area - {1:f2}\nVolume - {2:f2}", box.SurfaceArea(), box.LateralSurfaceArea(), box.Volume());
        }