New init for fraction

This commit is contained in:
Benjamin Bertrand 2016-03-09 10:49:29 +03:00
parent e34215a9a9
commit f5c64ce9e4

View File

@ -22,13 +22,14 @@ class Fraction(Explicable):
:param denom: the denominator :param denom: the denominator
""" """
super(Fraction, self).__init__()
self._num = num self._num = num
if denom == 0: if denom == 0:
raise ZeroDivisionError("Can't create Fraction: division by zero") raise ZeroDivisionError("Can't create Fraction: division by zero")
self._denom = denom self._denom = denom
self.isNumber = 1 self.isNumber = 1
pstf_tokens = self.compute_postfix_tokens()
super(Fraction, self).__init__(pstf_tokens)
def simplify(self): def simplify(self):
"""Simplify the fraction """Simplify the fraction
@ -87,8 +88,7 @@ class Fraction(Explicable):
else: else:
return copy(self) return copy(self)
@property def compute_postfix_tokens(self):
def postfix_tokens(self):
"""Postfix form of the fraction """Postfix form of the fraction
>>> f = Fraction(3, 5) >>> f = Fraction(3, 5)