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; }
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; }
public void IsSimpleReduce(int nominator, int denominator, bool result) { Fraction fraction = new Fraction(nominator, denominator); Assert.That(fraction.IsSimpleReduce(), Is.EqualTo(result)); }
public void HasSameNumberInNominatorAndDenominator(int nominator, int denominator, bool result) { Fraction fraction = new Fraction(nominator, denominator); Assert.That(fraction.HasSameNumberInNominatorAndDenominator(), Is.EqualTo(result)); }
public void FractionResult(int nominator, int denominator, float result) { Fraction fraction = new Fraction(nominator, denominator); Assert.That(fraction.Result, Is.EqualTo(result)); }
public void CanBeReduced(int nominator, int denominator, bool result) { Fraction fraction = new Fraction(nominator, denominator); Assert.That(fraction.CanBeReduced(), Is.EqualTo(result)); }