Esempio n. 1
0
        /// <summary>
        /// Overloaded + operator allows for more natural addition of integers to Fractions
        /// </summary>
        /// <param name="fractionAddend">RecipeFraction addend</param>
        /// <param name="integerAddend">Integer addend</param>
        /// <returns>Sum of addends</returns>
        public static RecipeFraction operator +(RecipeFraction fractionAddend, int integerAddend)
        {
            RecipeFraction fracCopy = fractionAddend.Copy();

            fracCopy.Add(integerAddend);
            return(fracCopy);
        }
Esempio n. 2
0
        //Overloaded operators required in class definition because cannot use overloaded operators from parent class as returns type of parent class

        /// <summary>
        /// Overloaded + operator allows for more natural addition of a Fraction to a RecipeFraction
        /// </summary>
        /// <param name="addend1">RecipeFraction addend</param>
        /// <param name="addend2">Fraction addend</param>
        /// <returns>Sum of addends</returns>
        public static RecipeFraction operator +(RecipeFraction addend1, Fraction addend2)
        {
            RecipeFraction fracCopy = addend1.Copy();

            fracCopy.Add(addend2);
            return(fracCopy);
        }