예제 #1
0
        /// <summary>
        /// Overloaded + operator allows for more natural Fraction addition
        /// </summary>
        /// <param name="addend1">NonNegativeFraction addend</param>
        /// <param name="addend2">Fraction addend</param>
        /// <returns>Sum of addends</returns>
        public static NonNegativeFraction operator +(NonNegativeFraction addend1, Fraction addend2)
        {
            NonNegativeFraction fracCopy = addend1.Copy();

            fracCopy.Add(addend2);
            return(fracCopy);
        }
예제 #2
0
        /// <summary>
        /// Overloaded + operator allows for more natural addition of integers to Fractions
        /// </summary>
        /// <param name="fractionAddend">NonNegativeFraction addend</param>
        /// <param name="integerAddend">Integer addend</param>
        /// <returns>Sum of addends</returns>
        public static NonNegativeFraction operator +(NonNegativeFraction fractionAddend, int integerAddend)
        {
            NonNegativeFraction fracCopy = fractionAddend.Copy();

            fracCopy.Add(integerAddend);
            return(fracCopy);
        }
예제 #3
0
        /// <summary>
        /// Overloaded / operator allows for more natural division of a Fraction by an integer
        /// </summary>
        /// <param name="dividend">NonNegativeFraction dividend</param>
        /// <param name="divisor">Integer divisor</param>
        /// <returns>NonNegativeFraction quotient</returns>
        public static NonNegativeFraction operator /(NonNegativeFraction dividend, int divisor)
        {
            NonNegativeFraction fracCopy = dividend.Copy();

            dividend.DivideBy(divisor);
            return(dividend);
        }
예제 #4
0
        /// <summary>
        /// Overloaded * operator allows for more natural multiplication of a Fraction by an integer
        /// </summary>
        /// <param name="fractionFactor">NonNegativeFraction factor</param>
        /// <param name="integerFactor">Integer factor</param>
        /// <returns>Product of factors</returns>
        public static NonNegativeFraction operator *(NonNegativeFraction fractionFactor, int integerFactor)
        {
            NonNegativeFraction fracCopy = fractionFactor.Copy();

            fractionFactor.MultiplyBy(integerFactor);
            return(fractionFactor);
        }
예제 #5
0
        /// <summary>
        /// Overloaded * operator allows for more natural multiplication of Fraction objects
        /// </summary>
        /// <param name="factor1">NonNegativeFraction factor</param>
        /// <param name="factor2">Fraction factor</param>
        /// <returns>Product of factors</returns>
        public static NonNegativeFraction operator *(NonNegativeFraction factor1, Fraction factor2)
        {
            NonNegativeFraction fracCopy = factor1.Copy();

            fracCopy.MultiplyBy(factor2);
            return(fracCopy);
        }
예제 #6
0
        /// <summary>
        /// Overloaded - operator allows for more natural subtraction of an integer from a Fraction
        /// </summary>
        /// <param name="minuend">NonNegativeFraction minuend</param>
        /// <param name="subtrahend">Integer subtrahend</param>
        /// <returns>NonNegativeFraction difference</returns>
        public static NonNegativeFraction operator -(NonNegativeFraction fraction, int num)
        {
            NonNegativeFraction fracCopy = fraction.Copy();

            fraction.Subtract(num);
            return(fraction);
        }
예제 #7
0
        /// <summary>
        /// Overloaded - operator allows for more natural subtraction of a Fraction from a Fraction
        /// </summary>
        /// <param name="minuend">NonNegativeFraction minuend</param>
        /// <param name="subtrahend">Fraction subtrahend</param>
        /// <returns>NonNegativeFraction difference</returns>
        public static NonNegativeFraction operator -(NonNegativeFraction minuend, Fraction subtrahend)
        {
            NonNegativeFraction fracCopy = minuend.Copy();

            fracCopy.Subtract(subtrahend);
            return(fracCopy);
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="recipe">string of recipe text</param>
 /// <param name="multiplier">NonNegativeFraction by which to multiply recipe</param>
 public RecipeConverter(string recipe, NonNegativeFraction multiplier)
 {
     _originalRecipe = recipe;
     _multiplier     = multiplier;
 }
예제 #9
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="text">String in which to find and replace measurements</param>
 /// <param name="multiplier">Amount by which to multiply measurements</param>
 public MeasurementConverter(string text, NonNegativeFraction multiplier)
 {
     this.text       = text;
     this.multiplier = multiplier;
 }