Пример #1
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);
                }
            }
        }
Пример #2
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);
                }
            }
        }