public ArithmeticOperationNode.ArithmeticOperation GetOperation(string op) { ArithmeticOperationNode.ArithmeticOperation operation = ArithmeticOperationNode.ArithmeticOperation.SUM; switch (op) { case "+": operation = ArithmeticOperationNode.ArithmeticOperation.SUM; break; case "-": operation = ArithmeticOperationNode.ArithmeticOperation.SUBTRACT; break; case "*": operation = ArithmeticOperationNode.ArithmeticOperation.MULTIPLY; break; case "/": operation = ArithmeticOperationNode.ArithmeticOperation.DIVIDE; break; default: throw new System.Exception("Invalid operator " + op); break; } return(operation); }
public ArithmeticOperationNode CreateNode(RootNode rootNode) { HighlightableButton highlightableButton = (GameObjectHelper.HasComponent <HighlightableButton>(this.gameObject)) ? this.GetComponent <HighlightableButton>() : null; IntegerNode field1 = GetField1Node(rootNode); IntegerNode field2 = GetField2Node(rootNode); // Converts the arithmetic operator choosen to the proper enum ArithmeticOperationNode.ArithmeticOperation operation = GetOperation(GetOperator()); ArithmeticOperationNode arithOpNode = new ArithmeticOperationNode(highlightableButton, field1, field2, operation); return(arithOpNode); }