From 8d38a7ddb4c67364825af0866867c6ded5025cd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Kaczmarek?= Date: Thu, 14 Dec 2017 18:44:10 +0100 Subject: [PATCH] in progress --- labs04/task03.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/labs04/task03.py b/labs04/task03.py index 88741a4..7180837 100644 --- a/labs04/task03.py +++ b/labs04/task03.py @@ -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 '' %(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() \ No newline at end of file