1
0
forked from tdwojak/Python2017
This commit is contained in:
Przemysław Kaczmarek 2017-12-14 20:31:14 +01:00
parent aed06ae658
commit e0beb9d336

View File

@ -27,9 +27,11 @@ class Point():
except IsNumericError as e: except IsNumericError as e:
print(e.msg) print(e.msg)
def __repr__(self): def __repr__(self):
return '<Point %s, is numeric: %s>' %(self.points,self.isnumeric) return '<Point %s, is numeric: %s>' %(self.points,self.isnumeric)
def __add__(self, other): def __add__(self, other):
try: try:
new = [] new = []
@ -58,7 +60,6 @@ class Point():
print(e.msg) print(e.msg)
return len return len
@staticmethod @staticmethod
def is_numeric(point): def is_numeric(point):
value=0 value=0
@ -67,13 +68,22 @@ class Point():
value+=1 value+=1
return value return value
def to_string(self):
point_tuple = tuple(self.points)
return str(point_tuple)
def __str__(self):
return (self.to_string())
def TestFunction(): def TestFunction():
punkt1=Point(['a',2,2]) punkt1=Point([1,2,2])
punkt2=Point([1,7,25]) punkt2=Point([1,7,25])
print(len(punkt1)) print('Ilosc wymiarow: ', len(punkt1))
print(len(punkt2)) print('Ilość wymiarów: ', len(punkt2))
print(punkt1,punkt2,punkt1+punkt2) punkt3=punkt1+punkt2
print('punkt1 + punkt2 = ',punkt3)
print(punkt1.to_string(),punkt1)
print(punkt2.to_string(),punkt2)
#punkt1.__str__()
TestFunction() TestFunction()