static void Main(string[] args) { CommandInputParser commandInputParser = new CommandInputParser(); Calculator calculator = new Calculator(); InputService inputService = new InputService(); OutputService outputService = new OutputService(); while (true) { string command = inputService.ReadCommand(); try { CommandTypes commandType = commandInputParser.ParseCommand(command); Arguments arguments = inputService.ReadArguments(); int result = calculator.Calculate(commandType, arguments); outputService.WriteResult(result.ToString()); } catch (Exception) { Console.WriteLine("Mistake!"); } } }
public CalculatorReplLoop() { commandInputParser = new CommandInputParser(); calculator = new Calculator(); inputService = new InputService(); outputService = new OutputService(); }