Example #1
0
        /// <summary>
        /// calculate the information about a shape
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnCalc_Click(object sender, EventArgs e)
        {
            OutputBox.Clear();
            _selectedShape.MainPoint = new Point(Convert.ToInt32(XText.Text), Convert.ToInt32(YText.Text));
            if (HeightText.Text != "")
            {
                _selectedShape.Height = Convert.ToInt32(HeightText.Text);
            }
            if (WidthText.Text != "")
            {
                _selectedShape.Width = Convert.ToInt32(WidthText.Text);
            }
            if (DepthText.Text != "")
            {
                _selectedShape.Depth = Convert.ToInt32(DepthText.Text);
            }
            if (RadiusText.Text != "")
            {
                _selectedShape.Radius = Convert.ToInt32(RadiusText.Text);
            }

            _selectedShape.SetAttributes();
            OutputBox.Text         = _selectedShape.ToString();
            ShapePic.ImageLocation = _selectedShape.Picture;
        }
Example #2
0
 private void buttonCalculate_Click(object sender, EventArgs e)
 {
     if (_selectedShape != null)
     {
         MessageBox.Show(_selectedShape.ToString());
     }
 }
Example #3
0
        public static void Main()
        {
            Console.WriteLine("Приложение для рассчета Периметра (P) и Площади (S) геометрических фигур.");
            bool  flag  = true;
            Shape shape = null;

            do
            {
                Console.WriteLine(@"ВЫберете одну из следующих опций:
                                    1 - Произвести рассчет круга
                                    2 - приозвести рассчет сферы
                                    3 - Произвести рассчет прямогульника
                                    4 - Произвести рассчет прямоугольного параллелепиедаs
                                    5 - Закончить работу в приложении");

                switch (Console.ReadLine())
                {
                case "1":
                    shape = Circle.EnteringParameters();
                    goto case "Print";

                case "2":
                    shape = Phere.EnteringParameters();;
                    goto case "Print";

                case "3":
                    shape = Rectangle.EnteringParameters();
                    goto case "Print";

                case "4":
                    shape = Coub.EnteringParameters();
                    goto case "Print";

                case "5":
                    flag = false;
                    break;

                case "Print":
                    Console.WriteLine(shape?.ToString());
                    break;

                default:
                    Console.WriteLine("Ошибка при вводе.");
                    break;
                }
            } while (flag);

            Console.WriteLine("Завершение работы с фигурами.");
            Console.ReadKey();
        }