From dc4921376359c2cec1d04ca0790077e085568c6c Mon Sep 17 00:00:00 2001 From: Jennifer86922 <121195727+Jennifer86922@users.noreply.github.com> Date: Fri, 24 Feb 2023 19:36:54 +0000 Subject: [PATCH] finish homework for 2/23 --- main.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 104be10..4da2819 100644 --- a/main.py +++ b/main.py @@ -1,2 +1,30 @@ +import math class Vector2d: - pass \ No newline at end of file + def __init__(self,x,y): + self.x=x + self.y=y + + def __repr__(self): + return f"Vector2d(x={self.x}, y={self.y})" + + def __str__(self): + return "Vector2d(self.x=xi,self.y=yj)" + + def __abs__(self): + return "Vector2d(self.x**.5, self.y**.5)" + + def __neg__(self): + return Vector2d(-self.x,-self.y) + + def __add__(self,other): + return Vector2d(self.x + other.x , self.y + other.y) + + def __eq__(self,other): + while True: + return "Vector2d({self.x} == other, {self.y} ==other)" + + def __sub__(self,other): + return "Vector2d(Vector2d(self.x,self.y) - other(self.x,self.y))" + + def angle(self): + return math.atan2(math.atan2(self.y,self.x)) \ No newline at end of file