public void Execute() { IMessagePrinter printer = uiFactory.CreateMessagePrinter(); List <String> args = new List <string>(); args.Add("Number"); args.Add("Error"); IDialogView dialog = uiFactory.CreateDialogView(); List <string> results = dialog.ShowSelectionDialog(args); double number = 0; double error = 0; if (!double.TryParse(results.ElementAt(0), out number)) { printer.Print("First input is not a number"); } if (!double.TryParse(results.ElementAt(1), out error)) { printer.Print("Second input is not a number"); } ITaylorExpansion exp = new ArctgExpansion(error, number); Result result = exp.Calculate(); printer.Print("Answer " + result.Answer); }
public void Execute() { IMessagePrinter printer = uiFactory.CreateMessagePrinter(); List <String> args = new List <string>(); args.Add("Error"); args.Add("Number"); args.Add("Power"); IDialogView dialog = uiFactory.CreateDialogView(); List <string> results = dialog.ShowSelectionDialog(args); double number = 0; double error = 0; double power = 0; bool parsingfailed = false; if (!double.TryParse(results.ElementAt(0), out error)) { parsingfailed = true; printer.Print("First input is not a number"); } if (!double.TryParse(results.ElementAt(1), out number)) { parsingfailed = true; printer.Print("Second input is not a number"); } if (!double.TryParse(results.ElementAt(1), out power)) { parsingfailed = true; printer.Print("Third input is not a number"); } if (!parsingfailed) { ITaylorExpansion exp = new Power(error, number, power); Result result = exp.Calculate(); if (result.Exist) { printer.Print("Answer " + result.Answer); } else { printer.Print("Answer does not exist"); } } }