1
0
Fork 0
Python2017/labs04/task03.py

36 lines
862 B
Python
Raw Normal View History

2017-12-03 13:05:05 +01:00
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
2017-12-14 18:44:10 +01:00
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()