Exemple #1
0
        public void BMIGO()
        {
            var IManage = new IManager();
            var o       = new CreateOperands();

            bool toContinue = true;

            while (toContinue)
            {
                IManage.PrintLn("\t1.Work with BMI  \t2. back to the Main menu ");
                IManage.PrintChoose();
                try
                {
                    int command = Convert.ToInt32(Console.ReadLine());

                    switch (command)
                    {
                    case 1:

                        string name   = IManage.InputMessage("Enter ur Name");
                        double weight = o.CreateOperand("enter Your mass in kg = ");
                        double height = o.CreateOperand("enter Your  hight in meters = ");
                        double BMIresult;
                        // var BMIUser = new BMIUser(name, weight, height);

                        var BMICalc = new MatchResult().ChooseMatchOp(nameof(BMI));
                        BMICalc.Calculate(weight, height);
                        BMIresult = BMICalc.result;
                        var BMIUser = new BMIUser(name, weight, height, BMIresult);
                        //historyBMI.Add(BMICalculate.result);

                        break;

                    case 2:
                        toContinue = false;
                        continue;
                    }
                    foreach (BMIUser record in BMIUser.historyBMI)
                    {
                        int a = BMIUser.historyBMI.LastIndexOf(record);
                        a++;
                        IManage.PrintLn($"\n record N  {a} was created {DateTime.Now}");
                        IManage.PrintLn(record.name + "\tYour enreted weight =" +
                                        record.weight + ", " +
                                        "height " + record.height +
                                        " BMI = " + record.BMI);
                    }
                }

                catch (Exception ex)
                {
                    IManage.PrintLn("\n");
                    IManage.PrintLn(ex.Message);
                }
            }
        }
Exemple #2
0
        public void CalcGo()
        {
            var  IManage    = new IManager();
            bool toContinue = true;

            while (toContinue)
            {
                IManage.WriteLnGreen("\t\t\t\tLet's start working");
                IManage.PrintLn("\n1.Numerical Calculator  \t2.BMI Calculator  \t3.Matrix Calculator   \t4.exit ");
                IManage.PrintChoose();
                try
                {
                    int command = Convert.ToInt32(Console.ReadLine());

                    switch (command)
                    {
                    case 1:
                        var CalcNum = new CalculatorNumerical();
                        CalcNum.BeginCalc();
                        break;

                    case 2:
                        var CalcBMI = new BMICalc();
                        CalcBMI.BMIGO();
                        break;

                    case 3:
                        var CalcMatrix = new MatrixCalc();
                        CalcMatrix.MatrixGO();
                        break;

                    case 4:
                        toContinue = false;
                        continue;
                    }
                }
                catch (Exception ex)
                {
                    IManage.PrintLn("\n");
                    IManage.PrintLn(ex.Message);
                }
            }
        }
Exemple #3
0
        public BMIUser(string name, double weight, double height, double BMI)
        {
            var IManage = new IManager();

            this.name   = name;
            this.weight = weight;
            this.height = height;
            this.BMI    = BMI;
            historyBMI.Add(this);

            IManage.PrintLn($" {name}. \t Your enreted weight = {weight} , height {height}" +
                            $" \nYour BMI = {BMI}");
            YouAre(BMI);
        }
Exemple #4
0
        public void MatrixGO()
        {
            var IManage = new IManager();
            var Filling = new CreateMarixes();

            int[,] C;

            bool           toContinue    = true;
            List <int[, ]> Matrixhistory = new List <int[, ]>();

            while (toContinue)
            {
                IManage.PrintLn("\n1.Start work wit matrixes   \t2.back to the Main menu ");
                IManage.PrintChoose();
                try
                {
                    int command = Convert.ToInt32(Console.ReadLine());

                    switch (command)
                    {
                    case 1:

                        var M1 = new MatrixCl();
                        M1.row    = Filling.GetSize(" row matrix 1 ");
                        M1.column = Filling.GetSize(" column matrix 1  ");
                        M1.matrix = new int[M1.row, M1.column];

                        var M2 = new MatrixCl();
                        M2.row = Filling.GetSize(" row matrix 1 ");
                        // while (M1.matrix.GetLength(1) != M2.matrix.GetLength(0))
                        while (M1.column != M2.row)
                        {
                            IManage.PrintLn("collumns 1Matrix must be = rows 2Matrix");
                            M2.row = Filling.GetSize(" row matrix 1 ");
                        }
                        M2.column = Filling.GetSize(" column matrix 1  ");
                        M2.matrix = new int[M2.row, M2.column];

                        IManage.PrintLn("fill matrix 1 ");
                        M1.matrix = Filling.FillMatrix(M1.row, M1.column);
                        Filling.Print(M1.matrix);

                        IManage.PrintLn("fill matrix 2 ");
                        M2.matrix = Filling.FillMatrix(M2.row, M2.column);
                        Filling.Print(M2.matrix);


                        var MatrixResult = new MatrixMultiply();
                        MatrixResult.CalculateMatrix(M1.matrix, M2.matrix);
                        //How i can set matrix as the first need to look how to transporent it
                        //  Matrixhistory.Add(MatrixResult.result);
                        Matrixhistory.Add(MatrixResult.result);
                        M1.matrix = MatrixResult.result;
                        //Matrixhistory.Add(M1.matrix);
                        break;

                    case 2:
                        toContinue = false;
                        continue;
                    }
                    foreach (int[,] recordM in Matrixhistory)
                    {
                        int a = Matrixhistory.LastIndexOf(recordM);
                        a++;
                        IManage.PrintLn($"\n record N  {a} was created {DateTime.Now}");
                    }
                    IManage.PrintLn($"\n\tDo you want use result ? " +
                                    "\nfor use result enter 'U' \tfor start work with numbers press something\n");
                    if (Console.ReadKey().Key == ConsoleKey.U)
                    {
                        continue;
                    }
                    else
                    {
                        continue;
                    }
                }
                catch (Exception ex)
                {
                    IManage.PrintLn("\n");
                    IManage.PrintLn(ex.Message);
                }
            }
        }
Exemple #5
0
        public void BeginCalc()
        {
            var IManage = new IManager();
            var o       = new CreateOperands();


            double A = o.CreateOperand("enter FIRST operand = ");
            double B = o.CreateOperand("enter SECOND operand = ");


            bool toContinue = true;

            List <double> history = new List <double>();

            while (toContinue)
            {
                IManage.PrintLn("\n1.Add  \t2.Subtract  \t3.Multiply   \t4.Divide  \t 5. back to the Main menu ");
                IManage.PrintChoose();
                try
                {
                    int command = Convert.ToInt32(Console.ReadLine());

                    switch (command)
                    {
                    case 1:
                        var add = new MatchResult().ChooseMatchOp(nameof(Add));
                        add.Calculate(A, B);
                        history.Add(add.result);
                        A = add.result;
                        break;

                    case 2:
                        var subtract = new MatchResult().ChooseMatchOp(nameof(Subtract));
                        subtract.Calculate(A, B);
                        history.Add(subtract.result);
                        A = subtract.result;
                        break;

                    case 3:
                        var multiply = new MatchResult().ChooseMatchOp(nameof(Multiply));
                        multiply.Calculate(A, B);
                        history.Add(multiply.result);
                        A = multiply.result;
                        break;

                    case 4:
                        var divide = new MatchResult().ChooseMatchOp(nameof(Divide));
                        divide.Calculate(A, B);
                        history.Add(divide.result);
                        A = divide.result;
                        break;

                    case 5:
                        toContinue = false;
                        continue;
                    }

                    foreach (double record in history)
                    {
                        int a = history.LastIndexOf(record);
                        a++;
                        IManage.PrintLn($"\n record N  {a} was created {DateTime.Now}");
                    }

                    //
                    IManage.PrintLn($"\n\tDo you want use result = " + A + " ? " +
                                    "\nfor use result enter 'U' \tfor start work with numbers press something\n");
                    if (Console.ReadKey().Key == ConsoleKey.U)
                    {
                        B = o.CreateOperand("\tEnter SECOND operand = ");
                        continue;
                    }
                    else
                    {
                        IManage.PrintLn("Let's start to work with numbers");
                        A = o.CreateOperand("enter FIRST operand = ");
                        B = o.CreateOperand("enter SECOND operand = ");
                        continue;
                    }
                    //
                }
                catch (Exception ex)
                {
                    IManage.PrintLn("\n");
                    IManage.PrintLn(ex.Message);
                }
            }
        }