Exemple #1
0
        public static void Circle()
        {
            double o_x = 0, o_y = 0, r = 0;

            string str;
            bool   cond;

            cond = false;
            while (!cond)
            {
                System.Console.WriteLine("Введите координату центра окружности X:");
                str = System.Console.ReadLine();
                try
                {
                    o_x = Double.Parse(str);
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine(ex.Message);
                    continue;
                }
                cond = true;
            }

            cond = false;
            while (!cond)
            {
                System.Console.WriteLine("Введите координату центра окружности Y:");
                str = System.Console.ReadLine();
                try
                {
                    o_y = Double.Parse(str);
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine(ex.Message);
                    continue;
                }
                cond = true;
            }

            cond = false;
            while (!cond)
            {
                System.Console.WriteLine("Введите радиус окружности R:");
                str = System.Console.ReadLine();
                try
                {
                    r = Double.Parse(str);
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine(ex.Message);
                    continue;
                }
                if (r <= 0)
                {
                    System.Console.WriteLine("Радиус должен быть больше нуля!");
                    continue;
                }
                cond = true;
            }

            cond = false;
            while (!cond)
            {
                try {
                    Circle cic = new Circle(o_x, o_y, r);
                    System.Console.WriteLine();
                    System.Console.WriteLine(cic.GetType());
                    System.Console.WriteLine("Фигура: " + cic.get_type());
                    System.Console.WriteLine("Площадь: " + cic.get_area());
                    System.Console.WriteLine("количество углов: " + cic.number_of_corners);
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine(ex.Message);
                    return;
                }
                cond = true;
            }
        }