public int GetOperandInt(string input) { int OperandInt; var operand = IoManager.ReadOperand(input); //get new while (!int.TryParse(operand, out OperandInt)) { Console.Write("Input must be double number !"); operand = IoManager.ReadOperand(input); } return(OperandInt); }
public string ConvertArrayToString(int[,] m1, int[,] m2, int[,] m3) { string stringarray = "matrix multiplication result : "; stringarray = IoManager.CreateString(m1, stringarray); stringarray += " * "; stringarray = IoManager.CreateString(m2, stringarray); stringarray += " = "; stringarray = IoManager.CreateString(m3, stringarray); return(stringarray); }
public double GetOperandLR(string input) { double OperandInt; var operand = IoManager.ReadOperand(input); //get new while (!double.TryParse(operand, out OperandInt)) { Console.Write("Input must be double number !"); operand = IoManager.ReadOperand(input); } if (LastResult == 0) { LastResult = OperandInt; } return(OperandInt); }
public void start() { mathRunnerMenu.isFirstLoop = true; exit = false; while (!exit) { try { mainMenu.MainMenuStart(); if (mainMenu.operationInput == "c") { mainMenu.clearLastResult(mainMenu.operationInput); } else if (mainMenu.operationInput == "h") { mainMenu.historyProgram(mainMenu.operationInput); } else if (mainMenu.operationInput == "q") { mainMenu.quitProgram(mainMenu.operationInput); } else if (mainMenu.operationInput == "b") { mainMenu.weight = mathRunnerMenu.GetOperand(mainMenu.weightMsg); mainMenu.height = mathRunnerMenu.GetOperand(mainMenu.heightMsg); mathRunnerMenu.SetInputsForBMI(mainMenu.Operation, mainMenu.weight, mainMenu.height); mainMenu.Operation.Calculate(); mainMenu.Operation.addToHistory(mainMenu.Operation.SaveDisplayRes()); } else if (mainMenu.operationInput == "m") { mathMatrixRunnerMenu.isFirstLoop = IoManager.Checker(mainMenu.LastResultMatrix, mathMatrixRunnerMenu.isFirstLoop); mainMenu.Matrix1 = mathMatrixRunnerMenu.isFirstLoop ? mathMatrixRunnerMenu.SetLengthM1() : mainMenu.LastResultMatrix; IoManager.WriteOperand(b); mainMenu.Matrix2 = mathMatrixRunnerMenu.SetLengthM2(mainMenu.Matrix1); mathMatrixRunnerMenu.SetInputsForMartix(mainMenu.Operation, mainMenu.Matrix1, mainMenu.Matrix2); mainMenu.Operation.Calculate(); mainMenu.Operation.addToHistory(mainMenu.Operation.SaveDisplayRes()); mainMenu.LastResultMatrix = mainMenu.Operation.MatrixResult; } else { mathRunnerMenu.isFirstLoop = IoManager.CheckerN(mainMenu.LastResult, mathRunnerMenu.isFirstLoop); mainMenu.FirstArgument = mathRunnerMenu.isFirstLoop ? mathRunnerMenu.GetOperand(mainMenu.firstMsg) : mainMenu.LastResult; mainMenu.SecondArgument = mathRunnerMenu.GetOperand(mainMenu.secondMsg); mathRunnerMenu.SetOperands(mainMenu.Operation, mainMenu.FirstArgument, mainMenu.SecondArgument); mainMenu.Operation.Calculate(); mainMenu.Operation.addToHistory(mainMenu.Operation.SaveDisplayRes()); mainMenu.LastResult = mainMenu.Operation.Result; } } catch (IncorrectInputException e) { Console.WriteLine(e.Message); } catch (EmptyHistoryException e) { Console.WriteLine(e.Message); } } }