示例#1
0
 public List<Fraction> CalculateSameAsReduced()
 {
     var same = new List<Fraction>();
     for (int nominator = 10; nominator <= 99; nominator++)
     {
         for (int denominator = nominator+1; denominator <= 99; denominator++)
         {
             Fraction f = new Fraction(nominator, denominator);
             if (f.IsSameResultAfterReduce())
             {
                 same.Add(f);
             }
         }
     }
     return same;
 }
示例#2
0
文件: Fraction.cs 项目: xszaboj/euler
 public bool IsSameResultAfterReduce()
 {
     if (CanBeReduced() && HasSameNumberInNominatorAndDenominator() && !IsSimpleReduce())
     {
         var reducedNominator = Nominator.Reduce(SameNumberInNominatorAndDenominator());
         var reducedDenominator = Denominator.Reduce(SameNumberInNominatorAndDenominator());
         var fraction = new Fraction(reducedNominator, reducedDenominator);
         return fraction.Result == this.Result;
     }
     return false;
 }
示例#3
0
 public void IsSimpleReduce(int nominator, int denominator, bool result)
 {
     Fraction fraction = new Fraction(nominator, denominator);
     Assert.That(fraction.IsSimpleReduce(), Is.EqualTo(result));
 }
示例#4
0
 public void HasSameNumberInNominatorAndDenominator(int nominator, int denominator, bool result)
 {
     Fraction fraction = new Fraction(nominator, denominator);
     Assert.That(fraction.HasSameNumberInNominatorAndDenominator(), Is.EqualTo(result));
 }
示例#5
0
 public void FractionResult(int nominator, int denominator, float result)
 {
     Fraction fraction = new Fraction(nominator, denominator);
     Assert.That(fraction.Result, Is.EqualTo(result));
 }
示例#6
0
 public void CanBeReduced(int nominator, int denominator, bool result)
 {
     Fraction fraction = new Fraction(nominator, denominator);
     Assert.That(fraction.CanBeReduced(), Is.EqualTo(result));
 }