示例#1
0
        public IStudyAssignment Multiply(IRationalFraction factor)
        {
            var result = new RationalFraction(Numerator * factor.Numerator, Denumenator * factor.Denumenator);

            result.Reduction();
            return(result);
        }
示例#2
0
        public IStudyAssignment Division(IRationalFraction divider)
        {
            if (divider.Numerator == 0)
            {
                throw new DivideByZeroException();
            }
            var result = new RationalFraction(Numerator * divider.Denumenator, Denumenator * divider.Numerator);

            result.Reduction();
            return(result);
        }
示例#3
0
        private RationalFraction Adder(int numerator2, int denumenator2)
        {
            if (Denumenator == denumenator2)
            {
                return(new RationalFraction(Numerator + numerator2, Denumenator));
            }
            var NOK     = GetLeastCommonMultiple(Denumenator, denumenator2);
            int addend1 = GetNewNumerator(Numerator, Denumenator, NOK);
            int addend2 = GetNewNumerator(numerator2, denumenator2, NOK);
            var result  = new RationalFraction(addend1 + addend2, NOK);

            result.Reduction();
            return(result);
        }