/// <summary> /// The GetHalfTablespoons method gets the greatest number of half tablespoons /// that can be formed from given number of teaspoons /// </summary> /// <param name="teaspoons">Fraction representing number of teaspoons</param> /// <returns>Greatest number of half tablespoons that can be formed</returns> private static int GetHalfTablespoons(Fraction teaspoons) { //equivelant of teaspoons/number_of_teaspoons_per_half_teaspoon, but need Fraction's div //method because they are both fractions return(Fraction.Div(teaspoons.Copy(), new Fraction(3, 2))); }
/// <summary> /// The Subtract method subtracts a Fraction from the NonNegativeFraction /// If the passed Fraction would cause the NonNegativeFraction to be negative, throws an ArgumentOutOfRangeException /// </summary> /// <param name="fraction">Fraction to subtract</param> protected override void Subtract(Fraction fraction) { fraction = fraction.Copy(); fraction *= -1; Add(fraction); }