static void Main(string[] args) { PrimitiveCalculator calc = new PrimitiveCalculator(); string input; while ((input = Console.ReadLine()) != "End") { var info = input.Split(); if (info[0] == "mode") { calc.ChangeStrategy(char.Parse(info[1])); continue; } int num1 = int.Parse(info[0]); int num2 = int.Parse(info[1]); Console.WriteLine(calc.PerformCalculation(num1, num2)); } }
public static void Main(string[] args) { PrimitiveCalculator calculator = new PrimitiveCalculator(new AdditionStrategy()); string inputInfo; while ((inputInfo = Console.ReadLine()) != "End") { string[] split = inputInfo.Split(); if (split[0] == "mode") { calculator.ChangeStrategy(char.Parse(split[1])); } else { int firstNumber = int.Parse(split[0]); int secondNumber = int.Parse(split[1]); Console.WriteLine(calculator.PerformCalculation(firstNumber, secondNumber)); } } }