コード例 #1
0
        private double Test1()
        {
            // Return 16
            _equation[0] = new TokenParenthesisOpen();
            _equation[1] = new TokenNumber3();
            _equation[2] = new TokenOperatorSubtract();
            _equation[3] = new TokenNumber1();
            _equation[4] = new TokenParenthesisClose();
            _equation[5] = new TokenOperatorMultiply();
            _equation[6] = new TokenParenthesisOpen();
            _equation[7] = new TokenNumber4();
            _equation[8] = new TokenOperatorMultiply();
            _equation[9] = new TokenNumber2();
            _equation[10] = new TokenParenthesisClose();
            return CalculateEquation(0, 10);

            // Return 8
            _equation[0] = new TokenParenthesisOpen();
            _equation[1] = new TokenNumber4();
            _equation[2] = new TokenOperatorMultiply();
            _equation[3] = new TokenParenthesisOpen();
            _equation[4] = new TokenNumber1();
            _equation[5] = new TokenOperatorAdd();
            _equation[6] = new TokenNumber3();
            _equation[7] = new TokenParenthesisClose();
            _equation[8] = new TokenParenthesisClose();
            _equation[9] = new TokenOperatorDivide();
            _equation[10] = new TokenNumber2();
            return CalculateEquation(0, 10);

            // Return 14
            _equation[0] = new TokenNumber4();
            _equation[1] = new TokenOperatorMultiply();
            _equation[2] = new TokenParenthesisOpen();
            _equation[3] = new TokenNumber3();
            _equation[4] = new TokenOperatorAdd();
            _equation[5] = new TokenNumber1();
            _equation[6] = new TokenOperatorDivide();
            _equation[7] = new TokenNumber2();
            _equation[8] = new TokenParenthesisClose();
            return CalculateEquation(0, 8);

            // Return 19
            _equation[0] = new TokenNumber4();
            _equation[1] = new TokenOperatorMultiply();
            _equation[2] = new TokenParenthesisOpen();
            _equation[3] = new TokenNumber2();
            _equation[4] = new TokenOperatorAdd();
            _equation[5] = new TokenNumber3();
            _equation[6] = new TokenParenthesisClose();
            _equation[7] = new TokenOperatorSubtract();
            _equation[8] = new TokenNumber1();
            return CalculateEquation(0, 8);

            // Return 36
            _equation[0] = new TokenNumber3();
            _equation[1] = new TokenOperatorMultiply();
            _equation[2] = new TokenNumber4();
            _equation[3] = new TokenOperatorMultiply();
            _equation[4] = new TokenParenthesisOpen();
            _equation[5] = new TokenNumber2();
            _equation[6] = new TokenOperatorAdd();
            _equation[7] = new TokenNumber1();
            _equation[8] = new TokenParenthesisClose();
            return CalculateEquation(0, 8);
        }
コード例 #2
0
 private void Initialize()
 {
     _numbersMaster[0] = new TokenNumber0();
     _numbersMaster[1] = new TokenNumber1();
     _numbersMaster[2] = new TokenNumber2();
     _numbersMaster[3] = new TokenNumber3();
     _numbersMaster[4] = new TokenNumber4();
     _numbersMaster[5] = new TokenNumber5();
     _numbersMaster[6] = new TokenNumber6();
     _numbersMaster[7] = new TokenNumber7();
     _numbersMaster[8] = new TokenNumber8();
     _numbersMaster[9] = new TokenNumber9();
     _operatorsMaster[0] = new TokenOperatorAdd();
     _operatorsMaster[1] = new TokenOperatorSubtract();
     _operatorsMaster[2] = new TokenOperatorMultiply();
     _operatorsMaster[3] = new TokenOperatorDivide();
 }