Exemplo n.º 1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (!(obj is RationalNumber))
            {
                return(false);
            }

            RationalNumber r = (RationalNumber)obj;

            if (r.numerator == this.numerator && r.denominator == this.denominator)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
 public object MultiplyBy(RationalNumber factor)
 {
     return(RationalNumber.Create(this.numerator * factor.numerator, this.denominator * factor.denominator));
 }
Exemplo n.º 3
0
 public object Subtract(RationalNumber number)
 {
     return(RationalNumber.Create((this.numerator * number.denominator) - (number.numerator * this.denominator), this.denominator * number.denominator));
 }
Exemplo n.º 4
0
 public object SubtractFrom(long number)
 {
     return(RationalNumber.Create((number * this.denominator) - this.numerator, this.denominator));
 }
Exemplo n.º 5
0
 public object Subtract(long number)
 {
     return(RationalNumber.Create(this.numerator - (number * this.denominator), this.denominator));
 }
Exemplo n.º 6
0
 public object Add(RationalNumber number)
 {
     return(RationalNumber.Create((this.numerator * number.denominator) + (number.numerator * this.denominator), this.denominator * number.denominator));
 }
Exemplo n.º 7
0
 public object Add(long number)
 {
     return(RationalNumber.Create(this.numerator + (number * this.denominator), this.denominator));
 }
Exemplo n.º 8
0
 public object DivideBy(RationalNumber divisor)
 {
     return(RationalNumber.Create(this.numerator * divisor.denominator, this.denominator * divisor.numerator));
 }
Exemplo n.º 9
0
 public object DivideTo(long divident)
 {
     return(RationalNumber.Create(this.denominator * divident, this.numerator));
 }