From a08a77fde992c0084ab22e40c5ba9bf62c8bfac6 Mon Sep 17 00:00:00 2001 From: bsw Date: Wed, 12 Dec 2018 17:29:14 +0800 Subject: [PATCH] scalar->scalar.x --- 01-data-model/vector2d.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/01-data-model/vector2d.py b/01-data-model/vector2d.py index 178f498..e00ab36 100644 --- a/01-data-model/vector2d.py +++ b/01-data-model/vector2d.py @@ -20,5 +20,9 @@ def __add__(self, other): y = self.y + other.y return Vector(x, y) - def __mul__(self, scalar): - return Vector(self.x * scalar, self.y * scalar) + def __mul__(self, scalar=3): + return Vector(self.x * scalar.x, self.y * scalar.y) + +print(Vector(5,5)) +print(Vector(5,3)*Vector(9,8)) +print((Vector(3,4))) \ No newline at end of file