发表于2008年10月的文章

Test from Writer

发表于2008年10月5日

A test post from Writer

fangqq

using System;
using System.Collections.Generic;
using System.Text;
using Calculator.Model;
 
namespace Calculator
{
    /// <summary>
    /// Math calculator.
    /// </summary>
    internal class MathCalculator : IMathCalculator
    {
        /// <summary>
        /// Creates a new instance of MathCalculator class.
        /// </summary>
        internal MathCalculator()
        {
        }
 
        #region IMathCalculator Members
 
        /// <summary>
        /// Calculates given equation and returns the result.
        /// </summary>
        /// <param name="equation">The equation to calculate.</param>
        /// <returns>The result of the given equation.</returns>
        public decimal Calculate(IMathEquation equation)
        {
            if (equation == null) throw new ArgumentNullException("equation");
 
            decimal result = 0;
 
            IMathValue resultValue = equation.Solve() as IMathValue;
 
            if (resultValue != null)
            {
                result = resultValue.Value;
            }
 
            return result;
        }
 
        #endregion
    }
}