示例#1
0
        static GeometricPatameter GetHypotheticalResults(ShapeType typeOfShape, TypeOfOperation typeOfOperation, double result)
        {
            GeometricPatameter hypotheticalResultParam = new GeometricPatameter();

            switch (typeOfShape)
            {
            case ShapeType.Triangle:

                switch (typeOfOperation)
                {
                case TypeOfOperation.Perimeter:
                    hypotheticalResultParam.Radius           = result / 2 * Math.PI;
                    hypotheticalResultParam.SideOfQuadrangle = result / 4;
                    break;

                case TypeOfOperation.Square:
                    hypotheticalResultParam.Radius           = Math.Sqrt(result / Math.PI);
                    hypotheticalResultParam.SideOfQuadrangle = Math.Sqrt(result);
                    break;
                }
                break;

            case ShapeType.Quadrangle:

                switch (typeOfOperation)
                {
                case TypeOfOperation.Perimeter:
                    hypotheticalResultParam.Radius         = result / 2 * Math.PI;
                    hypotheticalResultParam.SideOfTriangle = result / 3;
                    break;

                case TypeOfOperation.Square:
                    hypotheticalResultParam.Radius         = Math.Sqrt(result / Math.PI);
                    hypotheticalResultParam.SideOfTriangle = Math.Sqrt(4 * result / Math.Sqrt(3));
                    break;
                }
                break;

            case ShapeType.Circle:
                switch (typeOfOperation)
                {
                case TypeOfOperation.Perimeter:
                    hypotheticalResultParam.SideOfQuadrangle = result / 4;
                    hypotheticalResultParam.SideOfTriangle   = result / 3;
                    break;

                case TypeOfOperation.Square:
                    hypotheticalResultParam.SideOfTriangle   = Math.Sqrt(4 * result / Math.Sqrt(3));
                    hypotheticalResultParam.SideOfQuadrangle = Math.Sqrt(result);
                    break;
                }
                break;
            }

            return(hypotheticalResultParam);
        }
示例#2
0
        static void Main()
        {
            ShapeType       typeOfShape     = GetTypeOfShape();
            TypeOfOperation typeOfOperation = GetTypeOfOperation(typeOfShape);
            double          userValue       = GetUserValue(typeOfShape);
            GeometricShape  shape           = new GeometricShape(typeOfShape, userValue);
            double          result          = Calculate(shape, typeOfOperation);

            ShowSizesCalculations(result, typeOfOperation, typeOfShape);
            GeometricPatameter hypotheticalResults = GetHypotheticalResults(typeOfShape, typeOfOperation, result);

            ShowSizesHypotheticalCalculations(hypotheticalResults, typeOfOperation, typeOfShape);

            Console.ReadKey();
        }
示例#3
0
        static void ShowSizesHypotheticalCalculations(GeometricPatameter hypotheticalResultParam, TypeOfOperation typeOfOperation, ShapeType typeOfShape)
        {
            switch (typeOfShape)
            {
            case ShapeType.Triangle:

                Console.WriteLine($"Hypothetical radius of {ShapeType.Circle} is {hypotheticalResultParam.Radius}");
                Console.WriteLine($"the side of this {ShapeType.Quadrangle} is {hypotheticalResultParam.SideOfQuadrangle}");
                break;

            case ShapeType.Quadrangle:

                Console.WriteLine($"Hypothetical radius of {ShapeType.Circle} is {hypotheticalResultParam.Radius}");
                Console.WriteLine($"Hypothetical side of {ShapeType.Triangle} is {hypotheticalResultParam.SideOfTriangle}");
                break;

            case ShapeType.Circle:

                Console.WriteLine($"Hypothetical side of {ShapeType.Quadrangle} is {hypotheticalResultParam.SideOfQuadrangle}");
                Console.WriteLine($"Hypothetical side of {ShapeType.Triangle} is {hypotheticalResultParam.SideOfTriangle}");
                break;
            }
        }