Add 2 fractions works!

This commit is contained in:
2018-03-12 07:34:26 +03:00
parent 5f5fcc5a79
commit 98381f4512
4 changed files with 204 additions and 18 deletions

View File

@@ -46,6 +46,24 @@ class MOFraction(MO):
self._denominator = denominator
self.negative = negative
@property
def numerator(self):
""" Get the numerator. If self is negative, getting the opposite of the _numerator
"""
if self.negative:
return Tree("-", None, self._numerator)
return self._numerator
@property
def denominator(self):
return self._denominator
def inverse(self):
""" return the inverse fraction """
return MOFraction(self._denominator,
self._numerator,
self.negative)
# -----------------------------
# Reglages pour 'vim'