예제 #1
0
        Factorial(int value)
        {
            if (value < 0)
            {
                throw new ArgumentOutOfRangeException("value", Properties.LocalStrings.ArgumentPositive);
            }

            return(FactorialAlgorithm.Factorial(value));
        }
예제 #2
0
        public IMathLib GetMathLib(FactorialAlgorithm factorialAlgorithm)
        {
            IFactorialStrategy strategy;

            switch (factorialAlgorithm)
            {
            case FactorialAlgorithm.Functional:
                strategy = new FunctionalFactorial();
                break;

            case FactorialAlgorithm.Recursional:
                strategy = new RecursiveFactorial();
                break;

            default:
                throw new NotSupportedException(string.Format(Resources.Err_FactorialAlgorithmNotSupported, factorialAlgorithm));
            }
            return(new MathLib(strategy));
        }