Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var formulaSelection = new FormulaSelection();
            var getDataFromUser  = new GetDataFromUser();

            var circle     = new Circle();
            var triangle   = new Triangle();
            var quadrangle = new Quadrangle();

            while (true)
            {
                formulaSelection.ChooseShape();

                Console.WriteLine();

                formulaSelection.ChooseOperation();

                Console.WriteLine();

                formulaSelection.ChooseFormula(formulaSelection.TypeShape, formulaSelection.TypeOperation);

                switch (formulaSelection.TypeShape)
                {
                case 1:
                    getDataFromUser.InputDataRadius(formulaSelection.TypeOperation, ref circle);
                    getDataFromUser.Calculate(circle, formulaSelection.TypeOperation, formulaSelection.Formula);
                    getDataFromUser.Show(formulaSelection.TypeShape, formulaSelection.TypeOperation, formulaSelection.TxtShape, formulaSelection.TxtOperation, formulaSelection.TxtFormula, circle, triangle, quadrangle);

                    break;

                case 2:
                    getDataFromUser.InputDataTriangle(formulaSelection.TypeOperation, formulaSelection.Formula, ref triangle);
                    getDataFromUser.Calculate(triangle, formulaSelection.TypeOperation, formulaSelection.Formula);
                    getDataFromUser.Show(formulaSelection.TypeShape, formulaSelection.TypeOperation, formulaSelection.TxtShape, formulaSelection.TxtOperation, formulaSelection.TxtFormula, circle, triangle, quadrangle);

                    break;

                case 3:
                    getDataFromUser.InputDataQuadrangle(formulaSelection.TypeOperation, formulaSelection.Formula, ref quadrangle);
                    getDataFromUser.Calculate(quadrangle, formulaSelection.TypeOperation, formulaSelection.Formula);
                    getDataFromUser.Show(formulaSelection.TypeShape, formulaSelection.TypeOperation, formulaSelection.TxtShape, formulaSelection.TxtOperation, formulaSelection.TxtFormula, circle, triangle, quadrangle);

                    break;
                }

                Console.WriteLine();
                Console.WriteLine("Continue press Enter, Exit press Esc. ");

                if (Console.ReadKey().Key == ConsoleKey.Escape)
                {
                    break;
                }

                Console.WriteLine();
            }

            Console.ReadKey();
        }
Exemplo n.º 2
0
        public void Show(int shape, int operation, string txtShape, string txtOperation, string txtFormula, Circle circle, Triangle triangle, Quadrangle quadrangle)
        {
            var additionalShape = "";

            switch (shape)
            {
            case 1:
                if (operation == 1)
                {
                    _firstSide  = triangle.GetParameterFromSquare(_result);
                    _secondSide = quadrangle.GetParameterFromSquare(_result);

                    additionalShape = $"Triangle with side {_firstSide} and quadrangle with side {_secondSide} have the same area";
                }
                else if (operation == 2)
                {
                    _firstSide  = triangle.GetParameterFromPerimeter(_result);
                    _secondSide = quadrangle.GetParameterFromPerimeter(_result);

                    additionalShape = $"Triangle with side {_firstSide} and quadrangle with side {_secondSide} have the same perimeter";
                }

                break;

            case 2:
                if (operation == 1)
                {
                    _radius     = circle.GetParameterFromSquare(_result);
                    _secondSide = quadrangle.GetParameterFromSquare(_result);

                    additionalShape = $"Circle with radius {_radius} and quadrangle with side {_secondSide} have the same area";
                }
                else if (operation == 2)
                {
                    _radius     = circle.GetParameterFromPerimeter(_result);
                    _secondSide = quadrangle.GetParameterFromPerimeter(_result);

                    additionalShape = $"Circle with radius {_radius} and quadrangle with side {_secondSide} have the same perimeter";
                }

                break;

            case 3:
                if (operation == 1)
                {
                    _radius    = circle.GetParameterFromSquare(_result);
                    _firstSide = triangle.GetParameterFromSquare(_result);

                    additionalShape = $"Circle with radius {_radius} and triangle with side {_firstSide} have the same area";
                }
                else if (operation == 2)
                {
                    _radius    = circle.GetParameterFromPerimeter(_result);
                    _firstSide = triangle.GetParameterFromPerimeter(_result);

                    additionalShape = $"Circle with radius {_radius} and triangle with side {_firstSide} have the same perimeter";
                }

                break;
            }

            Console.WriteLine($"Shape: {txtShape}.\n" +
                              $"Operation: {txtOperation}.\n" +
                              $"Datas: {txtFormula}. \n" +
                              $"{txtOperation} is {_result} \n" +
                              additionalShape);
        }
Exemplo n.º 3
0
        public void InputDataQuadrangle(int operation, int formula, ref Quadrangle quadrangle)
        {
            if (operation == 1)
            {
                switch (formula)
                {
                case 1:
                    InputFirstSide();

                    quadrangle = new Quadrangle(_firstSide);

                    break;

                case 2:
                    InputHeight();
                    InputWidth();

                    quadrangle = new Quadrangle(_height, _width);

                    break;

                case 3:
                    InputFirstSide();
                    InputSecondSide();
                    InputThirdSide();
                    InputFourthSide();

                    quadrangle = new Quadrangle(_firstSide, _secondSide, _thirdSide, _fourthSide);

                    break;

                default:
                    break;
                }
            }

            else if (operation == 2)
            {
                switch (formula)
                {
                case 1:
                    InputFirstSide();

                    quadrangle = new Quadrangle(_firstSide);

                    break;

                case 2:
                    InputHeight();
                    InputWidth();

                    quadrangle = new Quadrangle(_height, _width);

                    break;

                case 3:
                    InputFirstSide();
                    InputSecondSide();
                    InputThirdSide();
                    InputFourthSide();

                    quadrangle = new Quadrangle(_firstSide, _secondSide, _thirdSide, _fourthSide);

                    break;

                default:
                    break;
                }
            }
        }