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); } } }
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); } } }