Spaces:
Running
on
Zero
Running
on
Zero
File size: 1,192 Bytes
0f43f8a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
from ifrac import Fraction
from .error_handler import ErrorHandler
class FractionOperations:
def __init__(self):
self.error_handler = ErrorHandler()
def add_fractions(self, fraction1, fraction2):
try:
result = fraction1 + fraction2
return result
except Exception as e:
self.error_handler.handle_error(e)
return None
def subtract_fractions(self, fraction1, fraction2):
try:
result = fraction1 - fraction2
return result
except Exception as e:
self.error_handler.handle_error(e)
return None
def multiply_fractions(self, fraction1, fraction2):
try:
result = fraction1 * fraction2
return result
except Exception as e:
self.error_handler.handle_error(e)
return None
def divide_fractions(self, fraction1, fraction2):
try:
result = fraction1 / fraction2
return result
except Exception as e:
self.error_handler.handle_error(e)
return None
def get_errors(self):
return self.error_handler.get_errors() |