示例#1
0
        public override Expression Solve()
        {
            switch (OperationType)
            {
            case ArthmeticOperationType.Add:
                return(Op1.Solve() + Op2.Solve());

            case ArthmeticOperationType.Div:
                return(Op1.Solve() / Op2.Solve());

            case ArthmeticOperationType.Mod:
                return(Op1.Solve() % Op2.Solve());

            case ArthmeticOperationType.Mult:
                return(Op1.Solve() * Op2.Solve());

            case ArthmeticOperationType.Sub:
                return(Op1.Solve() - Op2.Solve());

            default:
                throw new InvalidEnumArgumentException(nameof(OperationType));
            }
        }
示例#2
0
        public override double Solve(IDictionary <Variable, Operation> values)
        {
            switch (OperationType)
            {
            case ArthmeticOperationType.Add:
                return(Op1.Solve(values) + Op2.Solve(values));

            case ArthmeticOperationType.Div:
                return(Op1.Solve(values) / Op2.Solve(values));

            case ArthmeticOperationType.Mod:
                return(Op1.Solve(values) % Op2.Solve(values));

            case ArthmeticOperationType.Mult:
                return(Op1.Solve(values) * Op2.Solve(values));

            case ArthmeticOperationType.Sub:
                return(Op1.Solve(values) - Op2.Solve(values));

            default:
                throw new InvalidEnumArgumentException(nameof(OperationType));
            }
        }