public void BMIGO() { var IManage = new IManager(); var o = new CreateOperands(); bool toContinue = true; List <double> history = new List <double>(); while (toContinue) { IManage.PrintLn("\t1.Work with BMI \t2exit " + "\nchoose something:"); try { int command = Convert.ToInt32(Console.ReadLine()); switch (command) { case 1: double weight = o.CreateOperand("enter Your mass in kg = "); double height = o.CreateOperand("enter Your hight in meters = "); var User = new Person(weight, height); history.Add(User.CalculateIndex(weight, height)); break; case 2: toContinue = false; continue; } foreach (double record in history) { IManage.PrintLn($"\n record N {history.LastIndexOf(record)} was created {DateTime.Now}"); } } catch (Exception ex) { IManage.PrintLn("\n"); IManage.PrintLn(ex.Message); } } }
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>(); //double record = 0; int count = 0; while (toContinue) { IManage.PrintLn("\n1.Add \t2.Subtract \t3.Multiply \t4.Divide \t 5. exit " + "\nchoose something:"); 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; count++; break; case 2: var subtract = new MatchResult().ChooseMatchOp(nameof(Subtract)); subtract.Calculate(A, B); history.Add(subtract.result); A = subtract.result; count++; break; case 3: var multiply = new MatchResult().ChooseMatchOp(nameof(Multiply)); multiply.Calculate(A, B); history.Add(multiply.result); A = multiply.result; count++; break; case 4: var divide = new MatchResult().ChooseMatchOp(nameof(Divide)); divide.Calculate(A, B); history.Add(divide.result); A = divide.result; count++; break; case 5: toContinue = false; continue; /* * default: * Console.WriteLine("incorrect operation"); * break;*/ } foreach (double record in history) { int a = history.LastIndexOf(record); a++; IManage.PrintLn($"\n record N {a} was created {DateTime.Now}"); // IManage.Print($" record N {history.LastIndexOf(record)} was created {DateTime.Now}"); } //need to remove it... IManage.PrintLn($"Total count of records {count}"); 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); } } }