Example #1
0
        public areaResults getResults()
        {
            areaResults aResults = new areaResults();

            aResults.setValues(calculateArea(), getFourmula());
            return(aResults);
        }
        private void buttonCalculate_Click(object sender, RoutedEventArgs e)
        {
            areaResults areaReslt = new areaResults();
            String      shapeName = "";

            if (dataValidate())
            {
                switch (SelectedChoice)
                {
                case 1:
                    triangles triangle = new triangles();
                    triangle.setBase(double.Parse(textBoxBaseRadius.Text.Trim()));
                    triangle.setHeight(double.Parse(textBoxHeight.Text.Trim()));
                    areaReslt = triangle.getResults();
                    shapeName = "triangle";
                    break;

                case 2:
                    circles circle = new circles();
                    circle.setRadius(double.Parse(textBoxBaseRadius.Text.Trim()));
                    areaReslt = circle.getResults();
                    shapeName = "circle";
                    break;

                case 3:
                    rectangles rectangle = new rectangles();
                    rectangle.setBase(double.Parse(textBoxBaseRadius.Text.Trim()));
                    rectangle.setHeight(double.Parse(textBoxHeight.Text.Trim()));
                    areaReslt = rectangle.getResults();
                    shapeName = "rectangle";
                    break;
                }
                textBlockArea.Text    = "Area for " + shapeName + " = " + areaReslt.getArea().ToString("#.##");
                textBlockFormula.Text = "Formula for " + shapeName + ": " + areaReslt.getFormula().ToString();
            }
        }