forked from tdwojak/Python2017
in progress
This commit is contained in:
parent
cf0d9945b9
commit
8d38a7ddb4
@ -1,3 +1,36 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
class Point():
|
||||||
|
def __init__(self,list):
|
||||||
|
self.points=list
|
||||||
|
if len(list)==Point.is_numeric(self.points):
|
||||||
|
self.isnumeric=True
|
||||||
|
else:
|
||||||
|
self.isnumeric=False
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return '<Point %s, is numeric: %s>' %(self.points,self.isnumeric)
|
||||||
|
|
||||||
|
def __add__(self, other):
|
||||||
|
new=[]
|
||||||
|
for index in range(len(self.points)):
|
||||||
|
new.append(self.points[index]+other.points[index])
|
||||||
|
return new
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def is_numeric(point):
|
||||||
|
value=0
|
||||||
|
for element in point:
|
||||||
|
if isinstance(element, int) or isinstance(element, float):
|
||||||
|
value+=1
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def TestFunction():
|
||||||
|
punkt1=Point([12,12,2])
|
||||||
|
punkt2=Point([1,3,7])
|
||||||
|
print(punkt1,punkt2,punkt1+punkt2)
|
||||||
|
TestFunction()
|
Loading…
Reference in New Issue
Block a user