示例#1
0
        static void Main(string[] args)
        {
            Type boxType = typeof(Box);

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

            try
            {
                var boxParams = new double[3];

                for (int i = 0; i < 3; i++)
                {
                    boxParams[i] = double.Parse(Console.ReadLine());
                }

                var box = new Box(boxParams[0], boxParams[1], boxParams[2]);

                Console.WriteLine($"Surface Area - {box.GetSurfaceArea():F2}");
                Console.WriteLine($"Lateral Surface Area - {box.GetLateralSurfaceArea():F2}");
                Console.WriteLine($"Volume - {box.GetVolumeArea():F2}");
            }
            catch (ArgumentException ae)
            {
                Console.WriteLine(ae.Message);
            }
        }
示例#2
0
        public static void Main()
        {
            Type boxType = typeof(Box);

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

            var boxParams = new double[3];

            for (int i = 0; i < boxParams.Length; i++)
            {
                boxParams[i] = double.Parse(Console.ReadLine());
            }

            try
            {
                var box = new Box(boxParams[0], boxParams[1], boxParams[2]);

                var surfaceArea        = box.GetSurfaceArea();
                var lateralSurfaceArea = box.GetLateralSurfaceArea();
                var volume             = box.GetVolume();

                Console.WriteLine($"Surface Area – {surfaceArea:f2}");
                Console.WriteLine($"Lateral Surface Area – {lateralSurfaceArea:f2}");
                Console.WriteLine($"Volume – {volume:f2}");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
示例#3
0
        public static void Main(string[] args)
        {
            Type boxType = typeof(Box);

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

            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.GetSurfaceArea():F2}");

            Console.WriteLine($"Lateral Surface Area - {box.GetLateralSurfaceArea():F2}");

            Console.WriteLine($"Volume - {box.GetVolume():F2}");
        }
示例#4
0
        static void Main()
        {
            try
            {
                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);

                Console.WriteLine($"Surface Area - {box.GetSurfaceArea():F2}");
                Console.WriteLine($"Lateral Surface Area - {box.GetLateralSurfaceArea():F2}");
                Console.WriteLine($"Volume - {box.GetVolume():f2}");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
示例#5
0
        public static void Main(string[] args)
        {
            double length = double.Parse(Console.ReadLine());
            double width  = double.Parse(Console.ReadLine());
            double height = double.Parse(Console.ReadLine());

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

            Console.WriteLine(box.GetSurfaceArea());
            Console.WriteLine(box.GetLateralSurfaceArea());
            Console.WriteLine(box.GetVolume());
        }
        static void Main(string[] args)
        {
            double length = double.Parse(Console.ReadLine());
            double width  = double.Parse(Console.ReadLine());
            double heigth = double.Parse(Console.ReadLine());

            Box box = new Box(length, width, heigth);

            Console.WriteLine($"Surface Area - {box.GetSurfaceArea():f2}");
            Console.WriteLine($"Lateral Surface Area - {box.GetLateralSurfaceArea():f2}");
            Console.WriteLine($"Volume - {box.GetVolume():f2}");
        }
示例#7
0
文件: Program.cs 项目: AndrewTheM/OOP
        static void Main(string[] args)
        {
            double length = double.Parse(Console.ReadLine().Replace('.', ',')),
                   width  = double.Parse(Console.ReadLine().Replace('.', ',')),
                   height = double.Parse(Console.ReadLine().Replace('.', ','));

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

            Console.WriteLine($"Surface Area - {box.GetSurfaceArea():0.00}");
            Console.WriteLine($"Lateral Surface Area - {box.GetLateralSurfaceArea():0.00}");
            Console.WriteLine($"Volume - {box.GetVolume():0.00}");

            Console.ReadKey();
        }
示例#8
0
        public static void Main()
        {
            Type boxType = typeof(Box);

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

            double inputLength = double.Parse(Console.ReadLine());
            double inputWidth  = double.Parse(Console.ReadLine());
            double inputHeight = double.Parse(Console.ReadLine());

            Box box = new Box(inputLength, inputWidth, inputHeight);

            Console.WriteLine($"Surface Area - {box.GetSurfaceArea():F2}");
            Console.WriteLine($"Lateral Surface Area - {box.GetLateralSurfaceArea():F2}");
            Console.WriteLine($"Volume - {box.GetVolume():F2}");
        }
示例#9
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.GetSurfaceArea():f2}");
                Console.WriteLine($"Lateral Surface Area - {box.GetLateralSurfaceArea():f2}");
                Console.WriteLine($"Volume - {box.GetVolume():f2}");
            }
            catch (ArgumentException ae)
            {
                Console.WriteLine(ae.Message);
            }
        }
示例#10
0
        static void Main(string[] args)
        {
            try
            {
                double length = double.Parse(Console.ReadLine());
                double width  = double.Parse(Console.ReadLine());
                double height = double.Parse(Console.ReadLine());

                Box box = new Box(length, width, height);
                Console.WriteLine("Surface Area - {0:F2}", box.GetSurfaceArea());
                Console.WriteLine("Lateral Surface Area - {0:F2}", box.GetLateralSurfaceArea());
                Console.WriteLine("Volume - {0:F2}", box.GetVolume());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
示例#11
0
        static void Main(string[] args)
        {
            var lenght = double.Parse(Console.ReadLine());
            var width  = double.Parse(Console.ReadLine());
            var height = double.Parse(Console.ReadLine());

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

                Console.WriteLine($"Surface Area - {box.GetSurfaceArea():f2}");
                Console.WriteLine($"Lateral Surface Area - {box.GetLateralArea():f2}");
                Console.WriteLine($"Volume - {box.GetVolume():f2}");
            }
            catch (InvalidOperationException message)
            {
                Console.WriteLine(message.Message);
            }
        }
示例#12
0
        public static void Main()
        {
            var length = double.Parse(Console.ReadLine());
            var width  = double.Parse(Console.ReadLine());
            var height = double.Parse(Console.ReadLine());

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

                Console.WriteLine($"Surface Area - {box.GetSurfaceArea():F2}");
                Console.WriteLine($"Lateral Surface Area - {box.GetLateralSurfaceArea():F2}");
                Console.WriteLine($"Volume - {box.GetVolume():F2}");
            }
            catch (ArgumentException ae)
            {
                Console.WriteLine(ae.Message);
            }
        }