diff --git a/src/main/py/fractions.py b/src/main/py/fractions.py index 2d86a21..0445045 100644 --- a/src/main/py/fractions.py +++ b/src/main/py/fractions.py @@ -8,3 +8,7 @@ def reduceFraction(num, denom): num /= gcdOfFraction denom /= gcdOfFraction return (num, denom) + +def addFractions(num1, denom1, num2, denom2): + result_num = num1 + num2 + return (result_num, denom1) \ No newline at end of file diff --git a/src/test/py/test_fractions.py b/src/test/py/test_fractions.py index 8fe3a62..64bf0cb 100644 --- a/src/test/py/test_fractions.py +++ b/src/test/py/test_fractions.py @@ -18,6 +18,9 @@ class fractions(unittest.TestCase): def test_reduce_fraction_56_by_32_should_be_7_by_4(self): self.assertEqual(reduceFraction(56,32), (7,4)) + def test_add_fractions_1_by_5_and_2_by_5_should_be_3_by_5(self): + self.assertEqual(addFractions(1,5,2,5), (3,5)) + if __name__ == '__main__': unittest.main()