22 lines
585 B
Python
22 lines
585 B
Python
class Vector(object):
|
|
def __init__(self, coordinates):
|
|
try:
|
|
if not coordinates:
|
|
raise ValueError
|
|
self.coordinates = tuple(coordinates)
|
|
self.dimension = len(coordinates)
|
|
|
|
except ValueError:
|
|
raise ValueError('Die Koordinaten dürfen nicht leer sein')
|
|
|
|
except TypeError:
|
|
raise TypeError('Die Koordinaten müssen iterierbar sein')
|
|
|
|
|
|
def __str__(self):
|
|
return 'Vector: {}'.format(self.coordinates)
|
|
|
|
|
|
def __eq__(self, v):
|
|
return self.coordinates == v.coordinates
|