public void AdditionMiddleNegativeFraction() { Fraction fraction = new Fraction(2, 4); Fraction fractionTwo = new Fraction(-2, 4); Fraction fractionResult = fraction.Addition(fractionTwo); Assert.AreEqual(0, fractionResult.Numerator); Assert.AreEqual(1, fractionResult.Denominator); }
public void AdditionBigFraction() { Fraction fraction = new Fraction(1, 1); Fraction fractionTwo = new Fraction(100000000, 1); Fraction fractionResult = fraction.Addition(fractionTwo); Assert.AreEqual(100000001, fractionResult.Numerator); Assert.AreEqual(1, fractionResult.Denominator); }
public static void MainFraction() { int count = 0; Console.WriteLine("Введите количество дробей в массиве"); try { count = Operation.GetInt(); } catch (Exception ex) { Console.WriteLine(ex.Message); } Fraction sum = new Fraction(0, 1); Fraction[] array = new Fraction[count]; Random random = new Random(); for (int i = 0; i < count; i++) { Fraction value = new Fraction(random.Next(-10, 10), random.Next(1, 10)); array[i] = value; Console.WriteLine(array[i]); } Array.Sort(array); Console.WriteLine("\r\nОтсортированный массив:\r\n"); Operation.PrintArray(array); for (int i = 0; i < count; i++) { sum = sum.Addition(array[i]); } Console.WriteLine("\r\nСумма дробей = " + sum); Console.ReadKey(); }