public State(StateTypeEnum stateType, int leftOperand, int rightOperand, StateOperatorEnum op) { this.StateType = stateType; this.LeftOperand = leftOperand; this.RightOperand = rightOperand; this.Operator = op; }
private State OnOperator(StateOperatorEnum op) { switch (this.StateType) { case StateTypeEnum.Left: case StateTypeEnum.Operator: case StateTypeEnum.Enter: return(new State(StateTypeEnum.Operator, this.LeftOperand, this.RightOperand, op)); case StateTypeEnum.Right: if (op == StateOperatorEnum.Div && this.RightOperand == 0) { return(this); } else { return(this.OnEnter().OnOperator(op)); } default: return(this); } }