예제 #1
0
 /// <summary>
 /// Comparison of the two fractions
 /// </summary>
 /// <param name="compare_obj">Fraction, which is a comparison</param>
 /// <returns>result of comparison</returns>
 public int CompareTo(Rational compare_obj)
 {
     if (this < compare_obj)
         return -1;
     else if (this > compare_obj)
         return 1;
     else return 0;
 }
예제 #2
0
 /// <summary>
 /// Checks the equity between fraction
 /// </summary>
 /// <param name="other">Other fraction</param>
 /// <returns>Equity value</returns>
 public bool Equals(Rational other)
 {
     return CompareTo(other) == 0;
 }
예제 #3
0
 /// <summary>
 /// Clone fraction
 /// </summary>
 /// <returns>clone of fraction</returns>
 public Rational Clone()
 {
     Rational copy = new Rational(this.Numerator, this.Denominator);
     return copy;
 }