Vektoraddtion hinzugefügt und getestet
This commit is contained in:
12
vector.py
12
vector.py
@@ -22,7 +22,19 @@ class Vector(object):
|
|||||||
def __eq__(self, v):
|
def __eq__(self, v):
|
||||||
return self.coordinates == v.coordinates
|
return self.coordinates == v.coordinates
|
||||||
|
|
||||||
|
def plus(self,v):
|
||||||
|
new_coordinates = [x+y for x,y in zip(self.coordinates, v.coordinates)]
|
||||||
|
return Vector(new_coordinates)
|
||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
|
|
||||||
vektor_1 = Vector([1,2,3])
|
vektor_1 = Vector([1,2,3])
|
||||||
print vektor_1
|
print vektor_1
|
||||||
|
|
||||||
|
vektor_2 = Vector([1,2,3])
|
||||||
|
vektor_3 = Vector([-1,2,3])
|
||||||
|
|
||||||
|
print vektor_1 == vektor_2
|
||||||
|
print vektor_2 == vektor_3
|
||||||
|
|
||||||
|
print vektor_1.plus(vektor_2)
|
||||||
Reference in New Issue
Block a user