Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- class PrzedziałOtwarty:
- def __init__(self,lewy,prawy):
- if not isinstance(prawy, int) and isinstance(lewy, int) and lewy=='inf' and lewy=='-inf' and prawy=='inf' and prawy=='-inf' :
- print('Niepoprawne typy danych inicjalizujących obiekt')
- else:
- self.lewy=lewy
- self.prawy=prawy
- def jest_pusty(self):
- if (self.prawy<self.lewy):
- return True
- else:
- return False
- def __str__(self):
- if self.jest_pusty():
- return 'Przedział pusty.'
- return f'PrzedziałOtwarty({self.lewy}, {self.prawy})'
- def __eq__(self, inny):
- if (self.lewy==inny.lewy and self.prawy==inny.prawy or self.jest_pusty() and inny.jest_pusty()):
- return True
- else:
- return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement