1
0
forked from tdwojak/Python2017

in progress

This commit is contained in:
Przemysław Kaczmarek 2017-12-14 18:44:10 +01:00
parent cf0d9945b9
commit 8d38a7ddb4

View File

@ -1,3 +1,36 @@
#!/usr/bin/env python2
# -*- 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()