public void SetValue(T value) { INode <T> operation = new Value <T>(value); ICommand command = new CalculatorCommnad <T>(_calculator, operation); command.Execute(); _level++; _history.AddLast(command); }
public void Apply(Operation operation, INode <T> right) { INode <T> node = null; switch (operation) { case Operation.ADD: node = (_factory as INumericFactory <T>)?.GetAddOperation(_calculator.CurrentOperation, right); break; case Operation.MULTIPLY: node = (_factory as INumericFactory <T>)?.GetMultiplyOperation(_calculator.CurrentOperation, right); break; case Operation.DIVIDE: node = (_factory as INumericFactory <T>)?.GetDivideOperation(_calculator.CurrentOperation, right); break; case Operation.SUBTRACT: node = (_factory as INumericFactory <T>)?.GetSubtractOperation(_calculator.CurrentOperation, right); break; case Operation.SIN: node = (_factory as ITrigonometryFactory <T>)?.GetSinOperation(_calculator.CurrentOperation); break; } if (node == null) { throw new NotImplementedException($"No suitable implementation found for '{operation}' in the factory"); } ICommand command = new CalculatorCommnad <T>(_calculator, node); command.Execute(); _level++; _history.AddLast(command); }
public void Apply(Operation operation) { INode <T> node = null; switch (operation) { case Operation.SIN: node = (_factory as ITrigonometryFactory <T>)?.GetSinOperation(_calculator.CurrentOperation); break; case Operation.COS: node = (_factory as ITrigonometryFactory <T>)?.GetCosOperation(_calculator.CurrentOperation); break; } if (node == null) { throw new NotImplementedException($"No suitable implementation found for '{operation}' in the factory"); } ICommand command = new CalculatorCommnad <T>(_calculator, node); command.Execute(); _level++; _history.AddLast(command); }