private void bCalculate_Click(object sender, EventArgs e)
        {
            if (cbChoose.Text == "Circle")
            {
                lbAnswer.Items.Clear();
                _radius = Convert.ToInt32(tbRadius.Text);
                Circle circle = new Circle()
                {
                    Radius = _radius
                };
                lbAnswer.Items.Add("Circle Area with radius " + _radius + " is: " + circle.CalculateArea());
                lbAnswer.Items.Add("Circle circumference with radius " + _radius + " is: " + circle.CalculateCircumference());
            }

            else if (cbChoose.Text == "Square")
            {
                lbAnswer.Items.Clear();
                _side = Convert.ToInt32(tbSide.Text);
                Square square = new Square()
                {
                    Side = _side
                };
                lbAnswer.Items.Add("Square Area with radius " + _side + " is: " + square.CalculateArea());
                lbAnswer.Items.Add("Square circumference with radius " + _side + " is: " + square.CalculateCircumference());
            }

            else if (cbChoose.Text == "Rectangle")
            {
                lbAnswer.Items.Clear();
                _height = Convert.ToInt32(tbHeight.Text);
                _width  = Convert.ToInt32(tbWidth.Text);
                RectangleShape rectangleShape = new RectangleShape()
                {
                    Height = _height, Width = _width
                };
                lbAnswer.Items.Add("Rectangle Area with radius is: " + rectangleShape.CalculateArea());
                lbAnswer.Items.Add("Rectangle circumference with radius is: " + rectangleShape.CalculateCircumference());
            }

            else if (cbChoose.Text == "Right Angle Triangle")
            {
                lbAnswer.Items.Clear();
                _height = Convert.ToInt32(tbHeight.Text);
                _length = Convert.ToInt32(tbLength.Text);
                RightAngleTriangle rightAngleTriangle = new RightAngleTriangle()
                {
                    Height = _height, Length = _length
                };
                lbAnswer.Items.Add("Right Angle Triangle area with radius is: " + rightAngleTriangle.CalculateArea());
                lbAnswer.Items.Add("Right Angle Triangle circumference with radius is: " + rightAngleTriangle.CalculateCircumference());
            }
            else
            {
                lbAnswer.Items.Clear();
                _length = Convert.ToInt32(tbLength.Text);
                TriangleShape triangleShape = new TriangleShape()
                {
                    Length = _length
                };
                lbAnswer.Items.Add("Triangle area with radius is: " + triangleShape.CalculateArea());
                lbAnswer.Items.Add("Triangle circumference with radius is: " + triangleShape.CalculateCircumference());
            }
        }
Example #2
0
 private void CalculateAreaPressed(object sender, EventArgs e)
 {
     _rectangleShape = _rectangleShapeView.RectangleShape;
     _rectangleShape.CalculateArea();
     _rectangleShapeView.RectangleShape = _rectangleShape;
 }