FibonacciResultSet GetComputedResults(int? id) { int computeVal = id.GetValueOrDefault(); if (computeVal < 0) { computeVal = -1 * computeVal; } Calculator calc = new Calculator(); var results = calc.Compute(computeVal); return results; }
public ActionResult Calculate(int? num) { if (num == null) { // call invalid input view return View("NoResults"); } int calculateSize = num.GetValueOrDefault(); if (calculateSize < 0) { calculateSize = -1 * calculateSize; } Calculator calc = new Calculator(); var results = calc.Compute(calculateSize).GetAllResults(); return View(results); }
public void TestInitialize() { _fibWriter = new PlainTextFibonacciOutput(_testFilePath); _calculator = new FibonacciCalculator.Calculator(); }
private static void Main(string[] args) { var options = new CliOptions(); // parser fail case if (!Parser.Default.ParseArguments(args, options)) { Console.Write(options.GetUsage()); Environment.Exit(1); } // no input case if (args.Length == 0 || (options.InputFile == null && options.InputNumber == null && options.InteractiveMode == false)) { Console.Write(options.GetUsage()); Environment.Exit(1); } int numVal = 0; try { numVal = GetInputValue(options); } catch (InvalidFibonacciInputException e) { Console.WriteLine(e.Message); Environment.Exit(1); } // negative number case if (numVal < 0) { Console.WriteLine("Number must be positive."); Environment.Exit(1); } FibonacciCalculator.Calculator calc = new FibonacciCalculator.Calculator(); FibonacciResultSet results = calc.Compute(numVal); HandleOutput(options, results); }
public ActionResult Index() { Calculator calc = new Calculator(); var results = calc.Compute(50).GetAllResults(); return View(results); }